From patchwork Tue Jan 5 14:06:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 7955211 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5E5919F3E6 for ; Tue, 5 Jan 2016 14:07:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8249C20384 for ; Tue, 5 Jan 2016 14:07:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3B7320383 for ; Tue, 5 Jan 2016 14:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752010AbcAEOHg (ORCPT ); Tue, 5 Jan 2016 09:07:36 -0500 Received: from mail-pf0-f170.google.com ([209.85.192.170]:33965 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751676AbcAEOHe (ORCPT ); Tue, 5 Jan 2016 09:07:34 -0500 Received: by mail-pf0-f170.google.com with SMTP id e65so167954585pfe.1 for ; Tue, 05 Jan 2016 06:07:34 -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=JWDdUS31R0pRkypF3GRG0fKy+BD9cgOnp5LXO70/E/8=; b=h3VB+2XiApN5y0AcjSwgNKmKJia11kRo0XukHWme4DE51XJFfevXI6JDKOiDSZrott pymur/+4thHHr9GWjpldG/kxXt2Mbtm1deOIxrn8wX57rahSRyI08JHi2nIYX/pR0rgF BkPNCdhY5EQOzp3+k2jDxaK1bbQ6/wpZRqSDWieUFirSK16qJrhfyKoM/euHm66XmK0X C1akUWVgR89z8ep0Yo1IMP85tA4O/nH0EjnCWKnaqHJ64WjX8qNJY/n4r/BfREOYMBB4 YG0urL73Ac4EBG7/hI2t+IthfgBPhQGk/1vQyDIT7u+o4SRt2eGf4NTYV+ZpEZbiEYiv tyAw== X-Received: by 10.98.75.3 with SMTP id y3mr73369257pfa.115.1452002853969; Tue, 05 Jan 2016 06:07:33 -0800 (PST) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id y85sm61843870pfi.52.2016.01.05.06.07.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Jan 2016 06:07:33 -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 11/13] staging: wilc1000: use kmemdup instead of kmalloc/memcpy Date: Tue, 5 Jan 2016 23:06:55 +0900 Message-Id: <1452002817-30937-11-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1452002817-30937-1-git-send-email-chaehyun.lim@gmail.com> References: <1452002817-30937-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 replaces kmalloc followed by memcpy with kmemdup. It is also added error checking to return -ENOMEM when kmemdup is failed. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/host_interface.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 85aae56..8d022a0 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3704,12 +3704,16 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, msg.body.scan_info.arg = user_arg; msg.body.scan_info.ch_list_len = ch_list_len; - msg.body.scan_info.ch_freq_list = kmalloc(ch_list_len, GFP_KERNEL); - memcpy(msg.body.scan_info.ch_freq_list, ch_freq_list, ch_list_len); + msg.body.scan_info.ch_freq_list = kmemdup(ch_freq_list, + ch_list_len, + GFP_KERNEL); + if (!msg.body.scan_info.ch_freq_list) + return -ENOMEM; msg.body.scan_info.ies_len = ies_len; - msg.body.scan_info.ies = kmalloc(ies_len, GFP_KERNEL); - memcpy(msg.body.scan_info.ies, ies, ies_len); + msg.body.scan_info.ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!msg.body.scan_info.ies) + return -ENOMEM; result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); if (result) {