Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp109146rwb; Tue, 6 Dec 2022 18:04:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf4v8DJd0Ep0UDDeddAm7LNUxUZDN6MqiLWID0bInXG2j54B50H1T+nPm8JT94Gt8cXvCvkL X-Received: by 2002:a05:6a00:4c11:b0:56d:93d8:d81a with SMTP id ea17-20020a056a004c1100b0056d93d8d81amr72347820pfb.14.1670378674579; Tue, 06 Dec 2022 18:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670378674; cv=none; d=google.com; s=arc-20160816; b=obNvZyPKSRwThAjvJnQ42Sv+NiGrtE6R/cnn+PQHgWkSavE5DhU3JrZ5ruEy5t85GN p8x1fAdKfyoO6XVRIixNm2ZJWCXGhmvlAvo5KB1J/ADUlz0BVN0/h6EGvRNdU8d2toP4 OXE8rp5gljAD9Kr+tiCaruSEBSAfeXaln5F2mZBysF1U3fIgsUc7A70eK6azk4QSwxjt jGKd/4SgeBwMuFpO/KB6fLdR6wehMj9G1gydfDMTF+sQG3BHh18egkcvkjsv7SgxTSHN 5lvabwcE6bdxtw+D65K4XcGlusTR45nCI4lKNsG91fmT8VyF4SNdro/0CCR0UHpKBbTT fgsA== 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=0wjxsoqZRNhtMA+Nw5U+MWsVM1gQGZx3sjmjDc5hHdg=; b=o9/7XiGY7Srib5hlRq+wZgW5p0IRPYAUe8gDFelXwwoavfda3j/BdJUMoS27RAO9lq sUtrXoD+mHknZPdMmG4WstfEPUWmQZKu+ePuThIOzG+6MKjT3d7uKawQuXq7nH+5LwNv FVlii8lguAQOVKaKkxarND/uaRSj48IVsaMLeRTayHefpbQX2x/QPIBltkzSOZeJjNvZ scW+53MHtJQKZ8VJvCeCkXe0qystbLenLDCvUmW7H9GnYwDm61NmMuLXrPsBCAJHpy4Q nS6a6YZlhzGwjnHb1QzKFQ5oP8jgLsbvcHD8PGm9VU23zhdcBmhuuHgltRoyx5CzbjIQ 3r7w== 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 u13-20020a170902e80d00b0017a0e7aaf6bsi20664808plg.128.2022.12.06.18.04.25; Tue, 06 Dec 2022 18:04:34 -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 S229537AbiLGBNW (ORCPT + 77 others); Tue, 6 Dec 2022 20:13:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiLGBNU (ORCPT ); Tue, 6 Dec 2022 20:13:20 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C03B726F for ; Tue, 6 Dec 2022 17:13:19 -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 4NRfRf3WCGz4xVnK; Wed, 7 Dec 2022 09:13:18 +0800 (CST) Received: from szxlzmapp02.zte.com.cn ([10.5.231.79]) by mse-fl1.zte.com.cn with SMTP id 2B71DF9g056980; Wed, 7 Dec 2022 09:13:15 +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:13:16 +0800 (CST) Date: Wed, 7 Dec 2022 09:13:16 +0800 (CST) X-Zmail-TransId: 2b04638fe8ac20c82928 X-Mailer: Zmail v1.0 Message-ID: <202212070913161959936@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIGRybS92aXJ0aW86IHVzZSBzdHJzY3B5KCkgdG8gaW5zdGVhZCBvZiBzdHJuY3B5KCk=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B71DF9g056980 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638FE8AE.000 by FangMail milter! X-FangMail-Envelope: 1670375598/4NRfRf3WCGz4xVnK/638FE8AE.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638FE8AE.000/4NRfRf3WCGz4xVnK 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/virtio/virtgpu_vq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 9ff8660b50ad..7d95bc74b307 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -916,8 +916,7 @@ void virtio_gpu_cmd_context_create(struct virtio_gpu_device *vgdev, uint32_t id, cmd_p->hdr.ctx_id = cpu_to_le32(id); cmd_p->nlen = cpu_to_le32(nlen); cmd_p->context_init = cpu_to_le32(context_init); - strncpy(cmd_p->debug_name, name, sizeof(cmd_p->debug_name) - 1); - cmd_p->debug_name[sizeof(cmd_p->debug_name) - 1] = 0; + strscpy(cmd_p->debug_name, name, sizeof(cmd_p->debug_name)); virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); } -- 2.15.2