From patchwork Sun Nov 8 07:49:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 7577541 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 72F6E9F2F7 for ; Sun, 8 Nov 2015 07:50:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A12D0202F0 for ; Sun, 8 Nov 2015 07:50:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC67A2021F for ; Sun, 8 Nov 2015 07:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754859AbbKHHuo (ORCPT ); Sun, 8 Nov 2015 02:50:44 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:36003 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754474AbbKHHum (ORCPT ); Sun, 8 Nov 2015 02:50:42 -0500 Received: by pacdm15 with SMTP id dm15so141914376pac.3 for ; Sat, 07 Nov 2015 23:50:41 -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=czNxAY5Kzi0/OpKtj7biEpNKs076X5dIKGs6SJM0NDI=; b=lhn+Pvz6KbGkT5hJVWbed3Kqs1sTrJFiM6exCTiJoZ4VwUnw+KECAE2Q/hHRA4BYai bpq1uJsJO2+dO2xpzn9Vlwf86lrPgHdpWi9nZB4283IM4j7GeJPaA7k69XDcWMHI6n+k I2jJg0qlZwEOvdKZCvCB5iuvIZ+DY94kLBIuGUu+W89mRUDbTB0iTW3tQ+UaKf8a2m8b WJ8xRPggPM2DSUrniqf9HcFSUHwTtuzyCijNFYOBKNbdPim0YGzJDMLpeyueZoQfXCZv B9P6QEJWqRIk1ldntSh085KBvYUl4QLui/oeLY13JkMGIXjXVws2iTUrP8AmRhGTbHX+ Cdrw== X-Received: by 10.68.68.167 with SMTP id x7mr30249634pbt.140.1446969041665; Sat, 07 Nov 2015 23:50:41 -0800 (PST) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id tt7sm9435142pab.45.2015.11.07.23.50.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 07 Nov 2015 23:50:41 -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 23/32] staging: wilc1000: use kmemdup in host_int_add_rx_gtk Date: Sun, 8 Nov 2015 16:49:16 +0900 Message-Id: <1446968965-8958-23-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1446968965-8958-1-git-send-email-chaehyun.lim@gmail.com> References: <1446968965-8958-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, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 followed by memcpy to kmemdup. The error checking is also added when kmemdup is failed. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/host_interface.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0028bed..51b6ddb 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3296,8 +3296,11 @@ int host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *rx_gtk, key_len += TX_MIC_KEY_LEN; if (key_rsc) { - msg.body.key_info.attr.wpa.seq = kmalloc(key_rsc_len, GFP_KERNEL); - memcpy(msg.body.key_info.attr.wpa.seq, key_rsc, key_rsc_len); + msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc, + key_rsc_len, + GFP_KERNEL); + if (!msg.body.key_info.attr.wpa.seq) + return -ENOMEM; } msg.id = HOST_IF_MSG_KEY; @@ -3311,8 +3314,11 @@ int host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *rx_gtk, if (mode == STATION_MODE) msg.body.key_info.action = ADDKEY; - msg.body.key_info.attr.wpa.key = kmalloc(key_len, GFP_KERNEL); - memcpy(msg.body.key_info.attr.wpa.key, rx_gtk, gtk_key_len); + msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk, + key_len, + GFP_KERNEL); + if (!msg.body.key_info.attr.wpa.key) + return -ENOMEM; if (rx_mic) memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,