Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp877996rwb; Thu, 8 Dec 2022 04:14:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5kAHBTaUZ87ma0eg21VowApkg4jhCkZV6kJrk1cPoFv1GuyvzRCNF4wcMPoFJJzyhiAvLW X-Received: by 2002:a17:907:a705:b0:78d:3e6b:d402 with SMTP id vw5-20020a170907a70500b0078d3e6bd402mr61416357ejc.563.1670501646320; Thu, 08 Dec 2022 04:14:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670501646; cv=none; d=google.com; s=arc-20160816; b=s63BMlmho+tYvmPMcvIQNcqmtuJAEUqOWxF2Rc1V1KEiI3ia6DB/iPzw93CZ+b4Ejj ecevoa3c26KYX9dwN7vjg3rDqprhFbFfNdGM+awEFjE1l0IO/prS+KaKzD2ujjs4hACc OO3Sv87CqqqHz8oRuqZH7UMJqST6XYn/k8O9zTXLIWS274onzkZZshXl/eN0prMhC8/o niEZrbdrpwJSYh6CiZPSiEZ9/nPvu0Ywp3GAZE7xq9HfPfOTiKyTmTWEmpC71H0O+4R9 dE4ld+3ChutsFCoLOhNEajyXtS3EeKZkUu3UHhRY5P2jPB/fEeo9HpiUCgptG4n86y31 bnHg== 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=WE51mESWE/yC1sV9cSTA/rPZPrDEkfxC0/r05RvKVTc=; b=wj81+ZhlyxyI0tzFTsNEuNm24XK1a3k41fyNS+7SlySNs9BLDcvCOOB7XUSXtDdbZG RuFVRd/V3VMTNsdh9wl0lBQJA3JguF0JsZfS/Dvg3tIRH2fu8lpYWJY4hc5pOAn6zH9F e6br1smGNaGY02jEwG7b+Gda5m7bb4XQDktBwIGF4Gpx1R7uog0LvnsXU+y9W34kv207 Q3OKC/wIHvtc0rOsUaIFiXAgrjwL6s8TPNh0hFo/beVkE49d/cdPenvy4mmBrKXLgJcE u1pbhqC/F1iw4fJmT8UAaxSHkeojHX4jKVYc6vPrZXTzoQNVgsbyulIIZkqVZPqaVAJ5 tyHQ== 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 o11-20020a170906974b00b007c0cb3c5a70si14319341ejy.650.2022.12.08.04.13.47; Thu, 08 Dec 2022 04:14:06 -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 S230135AbiLHLyN (ORCPT + 72 others); Thu, 8 Dec 2022 06:54:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbiLHLxr (ORCPT ); Thu, 8 Dec 2022 06:53:47 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 585BB83252; Thu, 8 Dec 2022 03:53:29 -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 4NSXbr04Q3z8RTZJ; Thu, 8 Dec 2022 19:53:28 +0800 (CST) Received: from szxlzmapp01.zte.com.cn ([10.5.231.85]) by mse-fl1.zte.com.cn with SMTP id 2B8BrLOa009453; Thu, 8 Dec 2022 19:53:21 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp04[null]) by mapi (Zmail) with MAPI id mid14; Thu, 8 Dec 2022 19:53:25 +0800 (CST) Date: Thu, 8 Dec 2022 19:53:25 +0800 (CST) X-Zmail-TransId: 2b066391d0353162d1ea X-Mailer: Zmail v1.0 Message-ID: <202212081953254923522@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIG5ldDogaG5zMzogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B8BrLOa009453 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 6391D038.000 by FangMail milter! X-FangMail-Envelope: 1670500408/4NSXbr04Q3z8RTZJ/6391D038.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6391D038.000/4NSXbr04Q3z8RTZJ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, 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 --- 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