From: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexandru Gheorghiu <gheorghiuandru@gmail.com>
Subject: [PATCH] net: dns_resolver: Use kmemdup instead of kmalloc and memcpy
Date: Fri, 15 Mar 2013 20:21:52 +0200 [thread overview]
Message-ID: <1363371712-11566-1-git-send-email-gheorghiuandru@gmail.com> (raw)
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
reply other threads:[~2013-03-15 18:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363371712-11566-1-git-send-email-gheorghiuandru@gmail.com \
--to=gheorghiuandru@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).