lkml.org 
[lkml]   [2017]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] qed: fix unnecessary call to memset cocci warnings
On Fri, Nov 17, 2017 at 12:04 AM, Vasyl Gomonovych <gomonovych@gmail.com> wrote:
> Use kzalloc rather than kmalloc followed by memset with 0
>
> drivers/net/ethernet/qlogic/qed/qed_dcbx.c:1280:13-20: WARNING:
> kzalloc should be used for dcbx_info, instead of kmalloc/memset
> Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

While this looks okay per se now, it would be good if you put version
of the patch and add a changelog to it.

I think no need to resend this one, just for your information.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
> ---
> drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
> index 8f6ccc0c39e5..cc9e0dfcee48 100644
> --- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
> +++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
> @@ -1277,11 +1277,10 @@ static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn,
> {
> struct qed_dcbx_get *dcbx_info;
>
> - dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_ATOMIC);
> + dcbx_info = kzalloc(sizeof(*dcbx_info), GFP_ATOMIC);
> if (!dcbx_info)
> return NULL;
>
> - memset(dcbx_info, 0, sizeof(*dcbx_info));
> if (qed_dcbx_query_params(hwfn, dcbx_info, type)) {
> kfree(dcbx_info);
> return NULL;
> --
> 1.9.1
>



--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2017-11-17 17:21    [W:0.063 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site