* [PATCH] staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup
@ 2016-02-15 19:25 Amitoj Kaur Chawla
2016-02-17 13:37 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-15 19:25 UTC (permalink / raw)
To: outreachy-kernel
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
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
drivers/staging/rdma/hfi1/efivar.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/rdma/hfi1/efivar.c b/drivers/staging/rdma/hfi1/efivar.c
index e569f9f..47dfe25 100644
--- a/drivers/staging/rdma/hfi1/efivar.c
+++ b/drivers/staging/rdma/hfi1/efivar.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup
2016-02-15 19:25 [PATCH] staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup Amitoj Kaur Chawla
@ 2016-02-17 13:37 ` Julia Lawall
2016-02-17 13:42 ` Amitoj Kaur Chawla
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2016-02-17 13:37 UTC (permalink / raw)
To: Amitoj Kaur Chawla; +Cc: outreachy-kernel
On Tue, 16 Feb 2016, Amitoj Kaur Chawla wrote:
> 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
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
> drivers/staging/rdma/hfi1/efivar.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rdma/hfi1/efivar.c b/drivers/staging/rdma/hfi1/efivar.c
> index e569f9f..47dfe25 100644
> --- a/drivers/staging/rdma/hfi1/efivar.c
> +++ b/drivers/staging/rdma/hfi1/efivar.c
> @@ -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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup
2016-02-17 13:37 ` [Outreachy kernel] " Julia Lawall
@ 2016-02-17 13:42 ` Amitoj Kaur Chawla
0 siblings, 0 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-17 13:42 UTC (permalink / raw)
To: Julia Lawall; +Cc: outreachy-kernel
On Wed, Feb 17, 2016 at 7:07 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-17 13:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-15 19:25 [PATCH] staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup Amitoj Kaur Chawla
2016-02-17 13:37 ` [Outreachy kernel] " Julia Lawall
2016-02-17 13:42 ` Amitoj Kaur Chawla
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.