From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D20563FE6 for ; Sun, 3 Oct 2021 07:35:07 +0000 (UTC) Received: from ([60.208.111.195]) by unicom145.biz-email.net ((LNX1044)) with ASMTP (SSL) id WHF00045; Sun, 03 Oct 2021 15:28:45 +0800 Received: from localhost.localdomain (10.200.104.119) by jtjnmail201605.home.langchao.com (10.100.2.5) with Microsoft SMTP Server id 15.1.2308.14; Sun, 3 Oct 2021 15:28:43 +0800 From: Kai Song To: CC: , , , , , , , Kai Song Subject: [PATCH] staging: r8188eu: Use kmemdup() to replace kmalloc + memcpy Date: Sun, 3 Oct 2021 15:28:41 +0800 Message-ID: <20211003072841.215903-1-songkai01@inspur.com> X-Mailer: git-send-email 2.27.0 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.200.104.119] tUid: 2021100315284586480ab6b99732ccbe6ed0624a85d86d X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com fix memdup.cocci warning: drivers/staging/r8188eu/os_dep/ioctl_linux.c:4452:33-40: WARNING opportunity for kmemdup Generated by: scripts/coccinelle/api/memdup.cocci Signed-off-by: Kai Song --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 20f6182fd93c..71843690356a 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -4189,12 +4189,11 @@ static int rtw_wx_set_priv(struct net_device *dev, kfree(pmlmepriv->wps_probe_req_ie); pmlmepriv->wps_probe_req_ie = NULL; - pmlmepriv->wps_probe_req_ie = kmalloc(cp_sz, GFP_KERNEL); + pmlmepriv->wps_probe_req_ie = kmemdup(probereq_wpsie, cp_sz, GFP_KERNEL); if (!pmlmepriv->wps_probe_req_ie) { ret = -EINVAL; goto FREE_EXT; } - memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); pmlmepriv->wps_probe_req_ie_len = cp_sz; } goto FREE_EXT; -- 2.27.0