staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup
PATCH 1/1 staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup
Replace kmalloc and memcpy with kmemdup. Found using Coccinelle.
The semantic patch used to make this change can be found here:scripts/coccinelle/api/memdup.cocci
--- drivers/staging/rdma/hfi1/efivar.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rdma/hfi1/efivar.c +1 -2
@@ -127,13 +127,12 @@ static int read_efi_var(const char *name, unsigned long *size,* temporary buffer. Now allocate a correctly sized * buffer. */ - data =kmalloc (temp_size,GFP_KERNEL ); + data =kmemdup (temp_buffer, temp_size,GFP_KERNEL );if (!data) { ret = -ENOMEM ; goto fail; } -memcpy (data, temp_buffer, temp_size); *size = temp_size; *return_data = data;
Signature · 1 line
1.9.1
Quoted 4 lines · Amitoj Kaur Chawla
Replace kmalloc and memcpy with kmemdup. Found using Coccinelle.
The semantic patch used to make this change can be found here:
scripts/coccinelle/api/memdup.cocci
No need to change, but in this situation you can also put:
Generated-by: scripts/coccinelle/api/memdup.cocci
Quoted 34 lines
Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/staging/rdma/hfi1/efivar.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/rdma/hfi1/efivar.c +1
-3@@ -127,13 +127,12 @@ static int read_efi_var(const char *name, unsigned long *size,* temporary buffer. Now allocate a correctly sized * buffer. */ - data =kmalloc (temp_size,GFP_KERNEL ); + data =kmemdup (temp_buffer, temp_size,GFP_KERNEL );if (!data) { ret = -ENOMEM ; goto fail; } -memcpy (data, temp_buffer, temp_size); *size = temp_size; *return_data = data; --1.9.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160215192524.GA30333%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.
Quoted 4 lines · Julia Lawall
No need to change, but in this situation you can also put:
Generated-by:
scripts/coccinelle/api/memdup.cocci
Oh okay will take care in the future.
Thanks,
Amitoj