Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2324195rwb; Fri, 9 Dec 2022 00:10:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Jj9IajHIL9CbYtC9qgv86Xs5+hYFwpAflulEvgKNEFSp4s4/XdozCmFoj7oB+bwrs0673 X-Received: by 2002:a17:906:abcd:b0:7ad:2da5:36ec with SMTP id kq13-20020a170906abcd00b007ad2da536ecmr4415640ejb.41.1670573416886; Fri, 09 Dec 2022 00:10:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670573416; cv=none; d=google.com; s=arc-20160816; b=v0lyWPkKVlISmbYiGx5Oh0BeSeLAWwkk+yGDBEa2hG/b1oMRpaqNOT4kjsBGtNhaFN mz1b+lIsHDUGdrPL9nhkls1yE705+fEcIf0zYve9tqLpL37fwlf0HWxPVMTVmZIRYjJl 2ATpDY2aTCLHi3pwzulvd0CO9A0JEzMHtYbBFIyCS0kx55jTUkrpfjQ0g3C1POL23Qeu 4emdIcmeh/JtRpA2gZvFy1AZbqT59+cVZTSypARjm2tZWSA9hf+oTv23owOnuG55+9H6 YP1s/02ZdFXPIVDVhuFJZUe1XoQV66hB+2ydhO02+5ZwDY3n4qrzPmJ2uNpr/u9m7cVU 8dzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=ZNzgGD4eBJKo6ic8ykkKonOmtt1IavZ7PD4DrvAvA2w=; b=Ko1X7X1DTA5aIuAefkg9nCUOyC2XH3ci2vTlYD1MrVchWM33UHR1YGHdfuXGDmt453 6ALncz6/kkck4/030KmHAESXFRmhjQ7/FlVs7LpF7TIkK9IMUK8n/0v3W/7UGdPfD1t6 SVZ2LuUhCF0CYyaZQxe0QT2OALBHLNSEr/FEwX9Yh2yaIYna/cR0M9xfYCLSwYGDwJ0/ Zyi43uguAfZ46x3h6aKNfmxKXWJdUGWJV4RKDyv9B5OX8RaDIbY7akil1QPOVpqeC89o 4xLJokQe+Skm555QsU6eg8z+nVBPb6nCVXXTWxHtmvYrULUKwnTigUCUQG2zVJB2r76o aQZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp23-20020a1709073e1700b0078df1c345dcsi890739ejc.535.2022.12.09.00.09.59; Fri, 09 Dec 2022 00:10:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbiLIHjK (ORCPT + 73 others); Fri, 9 Dec 2022 02:39:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbiLIHjI (ORCPT ); Fri, 9 Dec 2022 02:39:08 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3818345090; Thu, 8 Dec 2022 23:39:07 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (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 4NT2vs60Wnz5BNS0; Fri, 9 Dec 2022 15:39:05 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl2.zte.com.cn with SMTP id 2B97cv5J009991; Fri, 9 Dec 2022 15:38:57 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp04[null]) by mapi (Zmail) with MAPI id mid14; Fri, 9 Dec 2022 15:38:59 +0800 (CST) Date: Fri, 9 Dec 2022 15:38:59 +0800 (CST) X-Zmail-TransId: 2b066392e613190d3cc0 X-Mailer: Zmail v1.0 Message-ID: <202212091538591375035@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIG5ldC1uZXh0XSBuZXQ6IGhuczM6IHVzZSBzdHJzY3B5KCkgdG8gaW5zdGVhZCBvZiBzdHJuY3B5KCk=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 2B97cv5J009991 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 6392E619.002 by FangMail milter! X-FangMail-Envelope: 1670571545/4NT2vs60Wnz5BNS0/6392E619.002/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6392E619.002/4NT2vs60Wnz5BNS0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- change for v2 - change the subject, replace linux-next with net-next. --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index cdf76fb58d45..55306fe8a540 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -639,13 +639,11 @@ static void hns3_get_drvinfo(struct net_device *netdev, return; } - strncpy(drvinfo->driver, dev_driver_string(&h->pdev->dev), + strscpy(drvinfo->driver, dev_driver_string(&h->pdev->dev), sizeof(drvinfo->driver)); - drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; - strncpy(drvinfo->bus_info, pci_name(h->pdev), + strscpy(drvinfo->bus_info, pci_name(h->pdev), sizeof(drvinfo->bus_info)); - drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0'; fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h); -- 2.15.2