Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp780355rdb; Sun, 28 Jan 2024 08:36:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOXMjtEml3fEzzMeN1WWnBrhMwa4deoSiOcbggechAhUllg3//vkSngsupdQBQidqXH39t X-Received: by 2002:a17:903:442:b0:1d8:a86b:b4bb with SMTP id iw2-20020a170903044200b001d8a86bb4bbmr3349510plb.27.1706459815328; Sun, 28 Jan 2024 08:36:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706459815; cv=pass; d=google.com; s=arc-20160816; b=gt0uCmVaUq69RPJEBsfqIED4XW3AXouQBLo082BET0sFaiIxq71aQUN/aKyCYUWa4x 8x0noHjeieS2q4JdsgSwVhVYyP2sgm21pqyaJ21JmRZdJmmF2FhT3giK3tp0kprO+kUs Glq5CN2Dq5m6B1lMVer3SK/XMlHEc3f9DC2e5xB2uvxcZ/VxKhQQ0HsQRhaCrU4Hdtbg Y5ueZn7AQH7gooAsBXUaweYFU3yB+AAXIkNVPrIP0DkwWhh4VPz/BT+n2fWMOG9F4WvF s3il8zfDDKhL71gmpK8fIpU9YA0W814twNonVP2oSc1d7y0GjvvcnnXPwL68OdyXrV7P MS4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4HCjt9IoGvygjRG3Nwl+UQNf6XskG1gzzsLfACdtxrw=; fh=lNzmrxjPJ2ncAokmJXynjxswSRN7Wy7p4aPzGSEzTBw=; b=BQNYhKcOdw+7mxLlzVX3kGlE6Zc6BuQ7ujIi1AW1da4p6J++YhpVuPKEqTnBrF6Oy2 eKWuPWBPuFhfYN7E/FJVdhSr/rLzZZb3TCcTY/nrnW9bU9SKav6btaPPHvkHIRotKuCy jYvkQ6gzZM0T3Th7AlHMCpzATH/TMAY5fhq4GMO26Yxuh/QSLvdUcK06AZBNy213ncEA oiWcbK/ZE+/xi9R646YBlzSHF5xWDIA/Lv8TA15o/B3mGc0Et9uZOEH70Iwe62zGA4XP uunzwRZmdw9lEUgTN75Pn5/DixtXM77GR/pSyGErWfmA4UzdINmCOzsDQuRIVM6vjKlH CoRQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FEljcN5H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41773-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p10-20020a170902eaca00b001d8ce19d806si1201594pld.526.2024.01.28.08.36.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 08:36:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FEljcN5H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41773-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 611CC281887 for ; Sun, 28 Jan 2024 16:36:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4041082D61; Sun, 28 Jan 2024 16:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FEljcN5H" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 605FE81AD7; Sun, 28 Jan 2024 16:14:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706458497; cv=none; b=AabAuLg0Ho2qPuGatVENPtS1tvjC1V+jnPe0d2ZXlY5Ugz2ksKDOMOY7YBdAvck7Cjp6Z0nWJLKCoyWdwT5O6NrDyiSBU9ZdbrTUMYG5LHLGrxSmAzvdzXdUUGzAEoA7XeSo7sHITPKLkmw8OngAaU8V6dbhObMQpP9FrUGCAtY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706458497; c=relaxed/simple; bh=3wnEuBYJIuAxOgJ0atveQdxSQORBkskoU+TVlblzDcY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UNEuaV9cftZ0blz0VlEa7sATBttirKy9VhTIYtAYoOVPCFFfZY/LXMedOv0Z76fRBfrSWQeDdrn7nXgM9jitFgumWl1DJmKkDxBnz2cVJNEn/IEeziB2XY6TWqum6V004g5PUfeek0cNDgMG7iHx1qyaKH3/QQcLt5QwetzZ4+w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FEljcN5H; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70B6CC433F1; Sun, 28 Jan 2024 16:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706458496; bh=3wnEuBYJIuAxOgJ0atveQdxSQORBkskoU+TVlblzDcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FEljcN5HZddlOQraN1M11H7JCughH/w6v2ZrLou0dMEYYG15TrO4tdmU/A13R8hjE 5iIq7FnFSE2YftV52ELelxJmsomC1QWAUHLFK9o5wE9FGmkow2uqR/s+28k+hkd5Y3 c83MhCyCeK4d/TCwYSh6QnFyVihCQblB/nNFJoGCKDuUoLk/+Eo9xC5Ll6gCPhXsMG hKFcows3GPdCvJpSpQL4RzXS+E3U7X01kRHvbBV/MoFlUoEnJrngIqyWeKk+Az4nAY JFQaPgpE7e2z9fYn+Z7DomoaVd3qtvpmb4y6EFgM2N1qKxjEBWeEovIB7uAoG/3qli 7jXCTibX9fHFg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhu Yanjun , Xuan Zhuo , Jakub Kicinski , Sasha Levin , mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, virtualization@lists.linux.dev, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 18/27] =?UTF-8?q?virtio=5Fnet:=20Fix=20"?= =?UTF-8?q?=E2=80=98%d=E2=80=99=20directive=20writing=20between=201=20and?= =?UTF-8?q?=2011=20bytes=20into=20a=20region=20of=20size=2010"=20warnings?= Date: Sun, 28 Jan 2024 11:14:03 -0500 Message-ID: <20240128161424.203600-18-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240128161424.203600-1-sashal@kernel.org> References: <20240128161424.203600-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.75 Content-Transfer-Encoding: 8bit From: Zhu Yanjun [ Upstream commit e3fe8d28c67bf6c291e920c6d04fa22afa14e6e4 ] Fix the warnings when building virtio_net driver. " drivers/net/virtio_net.c: In function ‘init_vqs’: drivers/net/virtio_net.c:4551:48: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Wformat-overflow=] 4551 | sprintf(vi->rq[i].name, "input.%d", i); | ^~ In function ‘virtnet_find_vqs’, inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8: drivers/net/virtio_net.c:4551:41: note: directive argument in the range [-2147483643, 65534] 4551 | sprintf(vi->rq[i].name, "input.%d", i); | ^~~~~~~~~~ drivers/net/virtio_net.c:4551:17: note: ‘sprintf’ output between 8 and 18 bytes into a destination of size 16 4551 | sprintf(vi->rq[i].name, "input.%d", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/virtio_net.c: In function ‘init_vqs’: drivers/net/virtio_net.c:4552:49: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 9 [-Wformat-overflow=] 4552 | sprintf(vi->sq[i].name, "output.%d", i); | ^~ In function ‘virtnet_find_vqs’, inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8: drivers/net/virtio_net.c:4552:41: note: directive argument in the range [-2147483643, 65534] 4552 | sprintf(vi->sq[i].name, "output.%d", i); | ^~~~~~~~~~~ drivers/net/virtio_net.c:4552:17: note: ‘sprintf’ output between 9 and 19 bytes into a destination of size 16 4552 | sprintf(vi->sq[i].name, "output.%d", i); " Reviewed-by: Xuan Zhuo Signed-off-by: Zhu Yanjun Link: https://lore.kernel.org/r/20240104020902.2753599-1-yanjun.zhu@intel.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/virtio_net.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 21d3461fb5d1..45f1a871b7da 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3474,10 +3474,11 @@ static int virtnet_find_vqs(struct virtnet_info *vi) { vq_callback_t **callbacks; struct virtqueue **vqs; - int ret = -ENOMEM; - int i, total_vqs; const char **names; + int ret = -ENOMEM; + int total_vqs; bool *ctx; + u16 i; /* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by * possible N-1 RX/TX queue pairs used in multiqueue mode, followed by @@ -3514,8 +3515,8 @@ static int virtnet_find_vqs(struct virtnet_info *vi) for (i = 0; i < vi->max_queue_pairs; i++) { callbacks[rxq2vq(i)] = skb_recv_done; callbacks[txq2vq(i)] = skb_xmit_done; - sprintf(vi->rq[i].name, "input.%d", i); - sprintf(vi->sq[i].name, "output.%d", i); + sprintf(vi->rq[i].name, "input.%u", i); + sprintf(vi->sq[i].name, "output.%u", i); names[rxq2vq(i)] = vi->rq[i].name; names[txq2vq(i)] = vi->sq[i].name; if (ctx) -- 2.43.0