From: walter harms <wharms@bfs.de>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: geoff@infradead.org, netdev@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, kernel-janitors@vger.kernel.org
Subject: Re: Inconsistent use of size argument in kzalloc and memcpy in 'drivers/net/ethernet/toshiba/ps3_gelic_wireless.c'
Date: Mon, 11 Apr 2016 12:04:19 +0200 [thread overview]
Message-ID: <570B76A3.70701@bfs.de> (raw)
In-Reply-To: <570B75A4.5070904@wanadoo.fr>
this is a case for kmemdup().
target->hwinfo=kmemdup(scan_info,be16_to_cpu(scan_info->size), GFP_KERNEL);
re,
wh
Am 11.04.2016 12:00, schrieb Christophe JAILLET:
> Hi,
>
> while looking at potential clean-up, I ended on the following code which
> looks spurious to me.
>
> We allocate 'be16_to_cpu(scan_info->size)' bytes, but then copy
> 'scan_info->size'.
> This is not consistent.
>
>
> I don't know which one is the correct one.
>
>
> CJ
>
> --- drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
> +++ /tmp/cocci-output-24201-0dddbd-ps3_gelic_wireless.c
> @@ -1616,13 +1616,10 @@ static void gelic_wl_scan_complete_event
> target->valid = 1;
> target->eurus_index = i;
> kfree(target->hwinfo);
> - target->hwinfo = kzalloc(be16_to_cpu(scan_info->size),
> - GFP_KERNEL);
> if (!target->hwinfo)
> continue;
>
> /* copy hw scan info */
> - memcpy(target->hwinfo, scan_info, scan_info->size);
> target->essid_len = strnlen(scan_info->essid,
> sizeof(scan_info->essid));
> target->rate_len = 0;
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2016-04-11 10:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-11 10:00 Inconsistent use of size argument in kzalloc and memcpy in 'drivers/net/ethernet/toshiba/ps3_gelic_wireless.c' Christophe JAILLET
2016-04-11 10:04 ` walter harms [this message]
2016-04-11 10:26 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=570B76A3.70701@bfs.de \
--to=wharms@bfs.de \
--cc=christophe.jaillet@wanadoo.fr \
--cc=geoff@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).