* [PATCH] usb: gadget: storage: Use kcalloc instead of kzalloc to allocate array
@ 2011-11-29 21:08 Thomas Meyer
2011-12-07 8:56 ` Felipe Balbi
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Meyer @ 2011-11-29 21:08 UTC (permalink / raw)
To: balbi, linux-usb, linux-kernel
The advantage of kcalloc is, that will prevent integer overflows which could
result from the multiplication of number of elements and size and it is also
a bit nicer to read.
The semantic patch that makes this change is available
in https://lkml.org/lkml/2011/11/25/107
Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
diff -u -p a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
--- a/drivers/usb/gadget/f_fs.c 2011-11-13 11:07:51.550550667 +0100
+++ b/drivers/usb/gadget/f_fs.c 2011-11-28 20:05:17.011277814 +0100
@@ -1408,7 +1408,7 @@ static int ffs_epfiles_create(struct ffs
ENTER();
count = ffs->eps_count;
- epfiles = kzalloc(count * sizeof *epfiles, GFP_KERNEL);
+ epfiles = kcalloc(count, sizeof(*epfiles), GFP_KERNEL);
if (!epfiles)
return -ENOMEM;
diff -u -p a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
--- a/drivers/usb/gadget/f_mass_storage.c 2011-11-28 19:36:48.006781560 +0100
+++ b/drivers/usb/gadget/f_mass_storage.c 2011-11-28 20:05:29.388010153 +0100
@@ -2763,7 +2763,7 @@ static struct fsg_common *fsg_common_ini
* Create the LUNs, open their backing files, and register the
* LUN devices in sysfs.
*/
- curlun = kzalloc(nluns * sizeof *curlun, GFP_KERNEL);
+ curlun = kcalloc(nluns, sizeof(*curlun), GFP_KERNEL);
if (unlikely(!curlun)) {
rc = -ENOMEM;
goto error_release;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: gadget: storage: Use kcalloc instead of kzalloc to allocate array
2011-11-29 21:08 [PATCH] usb: gadget: storage: Use kcalloc instead of kzalloc to allocate array Thomas Meyer
@ 2011-12-07 8:56 ` Felipe Balbi
0 siblings, 0 replies; 2+ messages in thread
From: Felipe Balbi @ 2011-12-07 8:56 UTC (permalink / raw)
To: Thomas Meyer; +Cc: balbi, linux-usb, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 438 bytes --]
On Tue, Nov 29, 2011 at 10:08:00PM +0100, Thomas Meyer wrote:
> The advantage of kcalloc is, that will prevent integer overflows which could
> result from the multiplication of number of elements and size and it is also
> a bit nicer to read.
>
> The semantic patch that makes this change is available
> in https://lkml.org/lkml/2011/11/25/107
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
applied, thanks
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-07 8:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-29 21:08 [PATCH] usb: gadget: storage: Use kcalloc instead of kzalloc to allocate array Thomas Meyer
2011-12-07 8:56 ` Felipe Balbi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®