From patchwork Mon Mar 26 19:41:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 10308577 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A1F3C600CC for ; Mon, 26 Mar 2018 19:41:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F6E3297D5 for ; Mon, 26 Mar 2018 19:41:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8420A297DC; Mon, 26 Mar 2018 19:41:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F646297D5 for ; Mon, 26 Mar 2018 19:41:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751398AbeCZTld (ORCPT ); Mon, 26 Mar 2018 15:41:33 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:55161 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751076AbeCZTlc (ORCPT ); Mon, 26 Mar 2018 15:41:32 -0400 X-IronPort-AV: E=Sophos;i="5.48,365,1517871600"; d="scan'208";a="320051576" Received: from ip-146.net-89-2-7.rev.numericable.fr (HELO [192.168.0.15]) ([89.2.7.146]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2018 21:41:30 +0200 Date: Mon, 26 Mar 2018 21:41:30 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Colin Ian King cc: kbuild-all@01.org, devel@driverdev.osuosl.org, Greg Kroah-Hartman , Aditya Shankar , Ganesh Krishna , linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: wilc1000: fix memdup.cocci warnings Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fengguang Wu drivers/staging/wilc1000/host_interface.c:946:32-39: WARNING opportunity for kmemdup drivers/staging/wilc1000/host_interface.c:970:30-37: WARNING opportunity for kmemdup Use kmemdup rather than duplicating its implementation Generated by: scripts/coccinelle/api/memdup.cocci Fixes: aaea2164bdff ("staging: wilc1000: check for kmalloc allocation failures") CC: Colin Ian King Signed-off-by: Fengguang Wu Signed-off-by: Julia Lawall --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-next head: 12a0148711a440f5b7111f95a34dfce88cdb47d6 commit: aaea2164bdff39697d0f1ec69dcae62632e37974 [400/412] staging: wilc1000: check for kmalloc allocation failures In the first hunk, should 6 be ETH_ALEN? host_interface.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -943,12 +943,12 @@ static s32 handle_connect(struct wilc_vi } if (conn_attr->bssid) { - hif_drv->usr_conn_req.bssid = kmalloc(6, GFP_KERNEL); + hif_drv->usr_conn_req.bssid = kmemdup(conn_attr->bssid, 6, + GFP_KERNEL); if (!hif_drv->usr_conn_req.bssid) { result = -ENOMEM; goto error; } - memcpy(hif_drv->usr_conn_req.bssid, conn_attr->bssid, 6); } hif_drv->usr_conn_req.ssid_len = conn_attr->ssid_len; @@ -967,15 +967,13 @@ static s32 handle_connect(struct wilc_vi hif_drv->usr_conn_req.ies_len = conn_attr->ies_len; if (conn_attr->ies) { - hif_drv->usr_conn_req.ies = kmalloc(conn_attr->ies_len, + hif_drv->usr_conn_req.ies = kmemdup(conn_attr->ies, + conn_attr->ies_len, GFP_KERNEL); if (!hif_drv->usr_conn_req.ies) { result = -ENOMEM; goto error; } - memcpy(hif_drv->usr_conn_req.ies, - conn_attr->ies, - conn_attr->ies_len); } hif_drv->usr_conn_req.security = conn_attr->security;