netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dns_resolver: Use kmemdup instead of kmalloc and memcpy
@ 2013-03-15 18:21 Alexandru Gheorghiu
  0 siblings, 0 replies; only message in thread
From: Alexandru Gheorghiu @ 2013-03-15 18:21 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, Alexandru Gheorghiu

Replace use of kmalloc followed by memcpy with kmemdup.
Patch found using coccinelle.

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

diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c
index c32be29..4ac62fb 100644
--- a/net/dns_resolver/dns_query.c
+++ b/net/dns_resolver/dns_query.c
@@ -146,11 +146,10 @@ int dns_query(const char *type, const char *name, size_t namelen,
 	len = upayload->datalen;
 
 	ret = -ENOMEM;
-	*_result = kmalloc(len + 1, GFP_KERNEL);
+	*_result = kmemdup(upayload->data, len + 1, GFP_KERNEL);
 	if (!*_result)
 		goto put;
 
-	memcpy(*_result, upayload->data, len + 1);
 	if (_expiry)
 		*_expiry = rkey->expiry;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-03-15 18:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-15 18:21 [PATCH] net: dns_resolver: Use kmemdup instead of kmalloc and memcpy Alexandru Gheorghiu

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).