Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/memstick/core/mspro_block: use kmemdup

Use kmemdup when some other buffer is immediately copied into allocated
region. It replaces call to allocation followed by memcpy, by a single
call to kmemdup.

[akpm@linux-foundation.org: remove unneeded cast to void*]
Link: http://lkml.kernel.org/r/1463665743-16269-1-git-send-email-falakreyaz@gmail.com
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Muhammad Falak R Wani and committed by
Linus Torvalds
de6cdcb5 a831979f

+1 -2
+1 -2
drivers/memstick/core/mspro_block.c
··· 1033 1033 } 1034 1034 msb->attr_group.name = "media_attributes"; 1035 1035 1036 - buffer = kmalloc(attr_len, GFP_KERNEL); 1036 + buffer = kmemdup(attr, attr_len, GFP_KERNEL); 1037 1037 if (!buffer) { 1038 1038 rc = -ENOMEM; 1039 1039 goto out_free_attr; 1040 1040 } 1041 - memcpy(buffer, (char *)attr, attr_len); 1042 1041 1043 1042 for (cnt = 0; cnt < attr_count; ++cnt) { 1044 1043 s_attr = kzalloc(sizeof(struct mspro_sys_attr), GFP_KERNEL);