From patchwork Thu Dec 24 07:52:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 7915521 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9E90DBEEE5 for ; Thu, 24 Dec 2015 07:53:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6AFC205E9 for ; Thu, 24 Dec 2015 07:53:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB87D205EA for ; Thu, 24 Dec 2015 07:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933259AbbLXHxh (ORCPT ); Thu, 24 Dec 2015 02:53:37 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:34913 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933192AbbLXHx3 (ORCPT ); Thu, 24 Dec 2015 02:53:29 -0500 Received: by mail-pf0-f179.google.com with SMTP id 78so62820359pfw.2 for ; Wed, 23 Dec 2015 23:53:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xybGGIGQCCyXhIpEe+YlXTxYZH+lKxrlDxcFOFHuDzI=; b=UZ/VVMjggg54p8tKon2WtWZ3iuy/LHLxkutBk79o2k1lBngxlk9WgYkhCBirqPckt7 SSZVAE1RVyuIvyE3kxxdb98qU9Q4kzftnD7lmlzovMWAUnhf5P7JmpL8wuP/6BoT9wM/ mN+WIk+hjTcfs8l3yt6ou+C2ip4wYWMFF0fX0cWoNr4ISdd3IzkYvJSfljlFc0VaOnME UCOZ8dC5XBt1A10gtFYGJS0Nj5p6Qq2nPM6iLn77ld1MT1AigBfbsSVzFUyJ6uw+cv53 +2z2nOAWSo1oruxGD2/sWjS12mqS0NaNEr8VGUqBX0WhJ/0Eeyw1A4XNXSxVFwQOKpiB HF1Q== X-Received: by 10.98.13.14 with SMTP id v14mr50520510pfi.21.1450943608660; Wed, 23 Dec 2015 23:53:28 -0800 (PST) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id ah10sm57028431pad.23.2015.12.23.23.53.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Dec 2015 23:53:28 -0800 (PST) From: Chaehyun Lim To: gregkh@linuxfoundation.org Cc: johnny.kim@atmel.com, austin.shin@atmel.com, chris.park@atmel.com, tony.cho@atmel.com, glen.lee@atmel.com, leo.kim@atmel.com, linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, Chaehyun Lim Subject: [PATCH 14/21] staging: wilc1000: use kmemdup instead of kmalloc and memcpy Date: Thu, 24 Dec 2015 16:52:32 +0900 Message-Id: <1450943559-20937-14-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1450943559-20937-1-git-send-email-chaehyun.lim@gmail.com> References: <1450943559-20937-1-git-send-email-chaehyun.lim@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch changes kmalloc/memcpy to kmemdup. It is also added error checking to return -ENOMEM if kmemdup is failed. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/host_interface.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 79f3d9f..6518942 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3398,20 +3398,23 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, msg.vif = vif; if (bssid) { - msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL); - memcpy(msg.body.con_info.bssid, bssid, 6); + msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL); + if (!msg.body.con_info.bssid) + return -ENOMEM; } if (ssid) { msg.body.con_info.ssid_len = ssid_len; - msg.body.con_info.ssid = kmalloc(ssid_len, GFP_KERNEL); - memcpy(msg.body.con_info.ssid, ssid, ssid_len); + msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL); + if (!msg.body.con_info.ssid) + return -ENOMEM; } if (ies) { msg.body.con_info.ies_len = ies_len; - msg.body.con_info.ies = kmalloc(ies_len, GFP_KERNEL); - memcpy(msg.body.con_info.ies, ies, ies_len); + msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!msg.body.con_info.ies) + return -ENOMEM; } if (hif_drv->hif_state < HOST_IF_CONNECTING) hif_drv->hif_state = HOST_IF_CONNECTING;