Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp112703rwb; Tue, 6 Dec 2022 18:07:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf4cFiYgfMxxpHbhzSS26l64EaO4sJudfaa9VxF4dDfhsnAF5WNRR8J9lYaJF2JuBtD+A0rs X-Received: by 2002:a17:90a:fb89:b0:218:ec4a:782e with SMTP id cp9-20020a17090afb8900b00218ec4a782emr68381096pjb.7.1670378845003; Tue, 06 Dec 2022 18:07:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670378844; cv=none; d=google.com; s=arc-20160816; b=SMCJZ8jfArACcORW3qpM+7I6oBHz21GP1pszpXBv/i9/BZOylK1hPK6mWxOJ2yxUxn 8ECruu8P8v3wmEWZhyHJWxK+WDjc7MjJrvY7Njsrf+BIs+YsmUs/v5LT8x1M//yOSjhC GBwTcqsoWV60/v0ReRzzDC7HdOHrQnOJF39qRbtz1bd8f9ojb2RUpk8634Zd8pXb/fV+ q4OaLcpzFELTmz+300/PeQVJRd2TAaoROPCSpppKcuVXDrVJK/VXFC75Prd4iFNqK+Fc DMeAV7r4e+5eqLiIkrlbjQhicMxLM4kB/fMSRl60VniH1Y1gtqTP+0yLSENLf1zdDwzh srMg== 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=qo1MlvXkrxFEKpWT3wlUv4PhafVKNSeJ3HhvXwanmpA=; b=d60Zla6MxeUK0rTVWckYVyxKV4zDQb4tY2+Kvihw8ltZVJMinzOCf1D9gdad5dgUp8 c7cPCxH8jd3fVLt3cuFgUpLTqrc8CmCD94twMuq1XNGureDrzy0etyESFSb/7qMkf7bL 93gjdb/QAcYr9VMcf5NBdmWboO3u+30CzoUwh4nNo0p7JW0eEMoMxWk8GbL1BcWSUdRq 82oIP7bzpUS2StMEAGazQX2xbcBnPsrTRX0GdVXWrPshQZYyVC4pNcCUPGDd3TeZjGMu U91f5/THyaB60dfGbc0/A00QgJsYBZn+QxcSS7UqdN4IIhw2OYErr3+XlXc8nHfmSGaf +27A== 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 o12-20020a056a0015cc00b005726c063927si6817291pfu.161.2022.12.06.18.07.15; Tue, 06 Dec 2022 18:07:24 -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 S229732AbiLGBLT (ORCPT + 77 others); Tue, 6 Dec 2022 20:11:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiLGBLR (ORCPT ); Tue, 6 Dec 2022 20:11:17 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E78DDDA for ; Tue, 6 Dec 2022 17:11:16 -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 4NRfPH1mPfz5BNRf; Wed, 7 Dec 2022 09:11:15 +0800 (CST) Received: from szxlzmapp06.zte.com.cn ([10.5.230.252]) by mse-fl1.zte.com.cn with SMTP id 2B71B7sg055208; Wed, 7 Dec 2022 09:11:07 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Wed, 7 Dec 2022 09:11:08 +0800 (CST) Date: Wed, 7 Dec 2022 09:11:08 +0800 (CST) X-Zmail-TransId: 2b04638fe82cffffffffe2d7a552 X-Mailer: Zmail v1.0 Message-ID: <202212070911086649831@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIGRybS9ub3V2ZWF1L252a20vY29yZS9maXJtd2FyZTogcmVwbGFjZSBzdHJuY3B5KCkgd2l0aAogc3Ryc2NweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B71B7sg055208 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638FE833.000 by FangMail milter! X-FangMail-Envelope: 1670375475/4NRfPH1mPfz5BNRf/638FE833.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638FE833.000/4NRfPH1mPfz5BNRf 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 --- drivers/gpu/drm/nouveau/nvkm/core/firmware.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c index fcf2a002f6cb..5554f907e0d4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c @@ -79,8 +79,7 @@ nvkm_firmware_get(const struct nvkm_subdev *subdev, const char *fwname, int ver, int i; /* Convert device name to lowercase */ - strncpy(cname, device->chip->name, sizeof(cname)); - cname[sizeof(cname) - 1] = '\0'; + strscpy(cname, device->chip->name, sizeof(cname)); i = strlen(cname); while (i) { --i; -- 2.15.2