From patchwork Fri Dec 23 02:37:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 13080598 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97847C10F1D for ; Fri, 23 Dec 2022 02:37:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230444AbiLWCh2 (ORCPT ); Thu, 22 Dec 2022 21:37:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbiLWCh1 (ORCPT ); Thu, 22 Dec 2022 21:37:27 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD8801F62A; Thu, 22 Dec 2022 18:37:26 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NdWYK3cgSz5PkHg; Fri, 23 Dec 2022 10:37:25 +0800 (CST) Received: from szxlzmapp02.zte.com.cn ([10.5.231.79]) by mse-fl1.zte.com.cn with SMTP id 2BN2bJbl067460; Fri, 23 Dec 2022 10:37:19 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Fri, 23 Dec 2022 10:37:21 +0800 (CST) Date: Fri, 23 Dec 2022 10:37:21 +0800 (CST) X-Zmail-TransId: 2b0463a51461ffffffffe8784f89 X-Mailer: Zmail v1.0 Message-ID: <202212231037210142246@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , , , , , Subject: =?utf-8?q?=5BPATCH_net-next=5D_brcm80211=3A_use_strscpy=28=29_to_in?= =?utf-8?q?stead_of_strncpy=28=29?= X-MAIL: mse-fl1.zte.com.cn 2BN2bJbl067460 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63A51465.000 by FangMail milter! X-FangMail-Envelope: 1671763045/4NdWYK3cgSz5PkHg/63A51465.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63A51465.000/4NdWYK3cgSz5PkHg Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Xu Panda The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings. Signed-off-by: Xu Panda Signed-off-by: Yang Yang Signed-off-by: Yang Yang --- drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c index b7df576bb84d..66336c87b0d9 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c @@ -584,8 +584,7 @@ struct dma_pub *dma_attach(char *name, struct brcms_c_info *wlc, rxextheadroom, nrxpost, rxoffset, txregbase, rxregbase); /* make a private copy of our callers name */ - strncpy(di->name, name, MAXNAMEL); - di->name[MAXNAMEL - 1] = '\0'; + strscpy(di->name, name, MAXNAMEL); di->dmadev = core->dma_dev;