From patchwork Wed Dec 7 01:13:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 30571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3146903wrr; Tue, 6 Dec 2022 17:21:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5NtOtBjlK8dIWA1EFRCMjuCuEEHJXx3mONlQV9xrsh4sNrM8iey7UFeXd2FpkVIYHplaBI X-Received: by 2002:a63:5b45:0:b0:478:b792:dea6 with SMTP id l5-20020a635b45000000b00478b792dea6mr11411521pgm.445.1670376062910; Tue, 06 Dec 2022 17:21:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670376062; cv=none; d=google.com; s=arc-20160816; b=B+P34QhzLuEP3bOuEiMkU/AURi88uKsuVACyK3J6kUHj9ec8vI1gSiAjcNntPV1sXk 8czgFzkgvSn9Y7yzqk2xLpowK9FihJmJ3XMqIOQUaMRTix901fGVmf5CqMKSSq/6t0vf hRue/58n3o8y6alISPMuFM/KvC+9BdfaSDtztYpRXBi+MopDt81Us9n6oRZDJF1/P+/d D9x4KmKgvKeT/M+y0ZCMHWlR9L8rwCVKurYSuz24Lt13WWxG+FQhnjprU7i2L68V+jXe 6GB1ZQUpOlP87HS9npN5SDL5Y2s2cy2ipXlnWY0saGwss+cmYsLoSkBoYlgZ6w/S6K/n qK4Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a17090274cb00b0017840d9d42esi17917521plt.582.2022.12.06.17.20.49; Tue, 06 Dec 2022 17:21:02 -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 + 99 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?q?=5BPATCH_linux-next=5D_drm/virtio=3A_use_strscpy=28=29_to?= =?utf-8?q?_instead_of_strncpy=28=29?= 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751516250463283450?= X-GMAIL-MSGID: =?utf-8?q?1751516250463283450?= 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); }