mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fuse: Use kcalloc instead of kzalloc to allocate array
@ 2011-11-29 21:08 Thomas Meyer
  2011-12-06 14:02 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Meyer @ 2011-11-29 21:08 UTC (permalink / raw)
  To: miklos, fuse-devel, 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/fs/fuse/file.c b/fs/fuse/file.c
--- a/fs/fuse/file.c 2011-11-13 11:08:00.957365615 +0100
+++ b/fs/fuse/file.c 2011-11-28 19:48:25.838294455 +0100
@@ -1804,7 +1804,7 @@ long fuse_do_ioctl(struct file *file, un
 	BUILD_BUG_ON(sizeof(struct fuse_ioctl_iovec) * FUSE_IOCTL_MAX_IOV > PAGE_SIZE);
 
 	err = -ENOMEM;
-	pages = kzalloc(sizeof(pages[0]) * FUSE_MAX_PAGES_PER_REQ, GFP_KERNEL);
+	pages = kcalloc(FUSE_MAX_PAGES_PER_REQ, sizeof(pages[0]), GFP_KERNEL);
 	iov_page = (struct iovec *) __get_free_page(GFP_KERNEL);
 	if (!pages || !iov_page)
 		goto out;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-06 14:02 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] fuse: Use kcalloc instead of kzalloc to allocate array Thomas Meyer
2011-12-06 14:02 ` Miklos Szeredi

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®