* [PATCH] tipc: Use kmemdup instead of kmalloc and memcpy
@ 2016-06-23 4:49 Amitoj Kaur Chawla
2016-06-27 7:37 ` Ying Xue
2016-06-27 13:59 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-06-23 4:49 UTC (permalink / raw)
To: jon.maloy, ying.xue, davem, netdev, tipc-discussion, linux-kernel
Cc: julia.lawall
Replace calls to kmalloc followed by a memcpy with a direct call to
kmemdup.
The Coccinelle semantic patch used to make this change is as follows:
@@
expression from,to,size,flag;
statement S;
@@
- to = \(kmalloc\|kzalloc\)(size,flag);
+ to = kmemdup(from,size,flag);
if (to==NULL || ...) S
- memcpy(to, from, size);
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
net/tipc/server.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/tipc/server.c b/net/tipc/server.c
index 2446bfb..38a6f33 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -411,13 +411,12 @@ static struct outqueue_entry *tipc_alloc_entry(void *data, int len)
if (!entry)
return NULL;
- buf = kmalloc(len, GFP_ATOMIC);
+ buf = kmemdup(data, len, GFP_ATOMIC);
if (!buf) {
kfree(entry);
return NULL;
}
- memcpy(buf, data, len);
entry->iov.iov_base = buf;
entry->iov.iov_len = len;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tipc: Use kmemdup instead of kmalloc and memcpy
2016-06-23 4:49 [PATCH] tipc: Use kmemdup instead of kmalloc and memcpy Amitoj Kaur Chawla
@ 2016-06-27 7:37 ` Ying Xue
2016-06-27 13:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Ying Xue @ 2016-06-27 7:37 UTC (permalink / raw)
To: Amitoj Kaur Chawla, jon.maloy, davem, netdev, tipc-discussion,
linux-kernel
Cc: julia.lawall
On 06/23/2016 12:49 PM, Amitoj Kaur Chawla wrote:
> Replace calls to kmalloc followed by a memcpy with a direct call to
> kmemdup.
>
> The Coccinelle semantic patch used to make this change is as follows:
> @@
> expression from,to,size,flag;
> statement S;
> @@
>
> - to = \(kmalloc\|kzalloc\)(size,flag);
> + to = kmemdup(from,size,flag);
> if (to==NULL || ...) S
> - memcpy(to, from, size);
>
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
> ---
> net/tipc/server.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/tipc/server.c b/net/tipc/server.c
> index 2446bfb..38a6f33 100644
> --- a/net/tipc/server.c
> +++ b/net/tipc/server.c
> @@ -411,13 +411,12 @@ static struct outqueue_entry *tipc_alloc_entry(void *data, int len)
> if (!entry)
> return NULL;
>
> - buf = kmalloc(len, GFP_ATOMIC);
> + buf = kmemdup(data, len, GFP_ATOMIC);
> if (!buf) {
> kfree(entry);
> return NULL;
> }
>
> - memcpy(buf, data, len);
> entry->iov.iov_base = buf;
> entry->iov.iov_len = len;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tipc: Use kmemdup instead of kmalloc and memcpy
2016-06-23 4:49 [PATCH] tipc: Use kmemdup instead of kmalloc and memcpy Amitoj Kaur Chawla
2016-06-27 7:37 ` Ying Xue
@ 2016-06-27 13:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-06-27 13:59 UTC (permalink / raw)
To: amitoj1606
Cc: jon.maloy, ying.xue, netdev, tipc-discussion, linux-kernel, julia.lawall
From: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Date: Thu, 23 Jun 2016 10:19:37 +0530
> Replace calls to kmalloc followed by a memcpy with a direct call to
> kmemdup.
>
> The Coccinelle semantic patch used to make this change is as follows:
> @@
> expression from,to,size,flag;
> statement S;
> @@
>
> - to = \(kmalloc\|kzalloc\)(size,flag);
> + to = kmemdup(from,size,flag);
> if (to==NULL || ...) S
> - memcpy(to, from, size);
>
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-27 14:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-23 4:49 [PATCH] tipc: Use kmemdup instead of kmalloc and memcpy Amitoj Kaur Chawla
2016-06-27 7:37 ` Ying Xue
2016-06-27 13:59 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).