mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: pstore: Replaced calls to kmalloc and memcpy with kmemdup
@ 2013-03-09 11:57 Alexandru Gheorghiu
  2013-03-10 23:23 ` Kees Cook
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandru Gheorghiu @ 2013-03-09 11:57 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Colin Cross, Kees Cook, Tony Luck, linux-kernel, Alexandru Gheorghiu

Replaced calls to kmalloc and memcpy with a single call to kmemdup.
This patch was found using coccicheck.

Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
---
 fs/pstore/ram.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 288f068..38babb3 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -156,10 +156,9 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
 	time->tv_nsec = 0;
 
 	size = persistent_ram_old_size(prz);
-	*buf = kmalloc(size, GFP_KERNEL);
+	*buf = kmemdup(persistent_ram_old(prz), size, GFP_KERNEL);
 	if (*buf == NULL)
 		return -ENOMEM;
-	memcpy(*buf, persistent_ram_old(prz), size);
 
 	return size;
 }
-- 
1.7.9.5


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

end of thread, other threads:[~2013-03-19  2:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-09 11:57 [PATCH] fs: pstore: Replaced calls to kmalloc and memcpy with kmemdup Alexandru Gheorghiu
2013-03-10 23:23 ` Kees Cook
2013-03-19  2:41   ` Anton Vorontsov

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®