linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: hariprasath.elango@gmail.com
To: aditya.shankar@microchip.com, ganesh.krishna@microchip.com
Cc: hariprasath.elango@gmail.com,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] staging: wilc1000: use kmemdup to replace kmalloc/memcpy
Date: Tue, 13 Mar 2018 18:19:32 +0530	[thread overview]
Message-ID: <20180313124932.15038-1-hariprasath.elango@gmail.com> (raw)

From: HariPrasath Elango <hariprasath.elango@gmail.com>

kmalloc followed by memcpy can be replaced by kmemdup.Also added the
related error handling part

Signed-off-by: HariPrasath Elango <hariprasath.elango@gmail.com>
---
 drivers/staging/wilc1000/host_interface.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 0fac8e1..4ae2da6 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -992,9 +992,13 @@ static s32 handle_connect(struct wilc_vif *vif,
 
 	if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
 		info_element_size = hif_drv->usr_conn_req.ies_len;
-		info_element = kmalloc(info_element_size, GFP_KERNEL);
-		memcpy(info_element, hif_drv->usr_conn_req.ies,
-				info_element_size);
+		info_element = kmemdup(hif_drv->usr_conn_req.ies,
+				       info_element_size,
+				       GFP_KERNEL);
+		if (!info_element) {
+			result = -ENOMEM;
+			goto ERRORHANDLER;
+		}
 	}
 
 	wid_list[wid_cnt].id = (u16)WID_11I_MODE;
-- 
2.10.0.GIT

             reply	other threads:[~2018-03-13 12:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 12:49 hariprasath.elango [this message]
2018-03-14 11:38 ` [PATCH] staging: wilc1000: use kmemdup to replace kmalloc/memcpy Greg Kroah-Hartman
2018-03-14 12:21   ` <Hariprasath Elango>

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=20180313124932.15038-1-hariprasath.elango@gmail.com \
    --to=hariprasath.elango@gmail.com \
    --cc=aditya.shankar@microchip.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=ganesh.krishna@microchip.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@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).