🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25619

[PATCH net-next] net: prestera: size the firmware version buffer

#25619
From: Aibing Chen
Date: Wed, 02 Dec 2026 05:15
43 lines
10096 bytes
prestera_dl_info_get() formats the firmware revision with

	snprintf(buf, sizeof(buf), "%d.%d.%d",
		 sw->dev->fw_rev.maj, sw->dev->fw_rev.min,
		 sw->dev->fw_rev.sub);

into a 16 byte buffer.  The three fields are u16, so each can print up to
five digits and the format can produce 18 bytes including the
terminator.  gcc reports this in a W=1 build, and CONFIG_WERROR turns the
warning into a build failure:

  drivers/net/ethernet/marvell/prestera/prestera_devlink.c:359:43: error:
    '%d' directive output may be truncated writing between 1 and 5 bytes
    into a region of size between 4 and 12 [-Werror=format-truncation=]

The values come from the device firmware and are small in practice, but
gcc analyses the full u16 range.  Size the buffer for the widest string
the format allows, "65535.65535.65535", so that the reported version can
never be cut.

No functional change for the versions seen in practice.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202501110646.aGxZ97Ug-lkp@intel.com/
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
 drivers/net/ethernet/marvell/prestera/prestera_devlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_devlink.c b/drivers/net/ethernet/marvell/prestera/prestera_devlink.c
index 33dea101b..d5a04a4bb 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_devlink.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_devlink.c
@@ -354,7 +354,7 @@ static int prestera_dl_info_get(struct devlink *dl,
 				struct netlink_ext_ack *extack)
 {
 	struct prestera_switch *sw = devlink_priv(dl);
-	char buf[16];
+	char buf[sizeof("65535.65535.65535")];
 
 	snprintf(buf, sizeof(buf), "%d.%d.%d",
 		 sw->dev->fw_rev.maj,
Technical Details
Message-ID: <20261202051549.927-1-chenaibing@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375571-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375571-linux-kernel-netdev=dewy.ru
From: chenaibing@cmss.chinamobile.com (Aibing Chen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next] net: prestera: size the firmware version buffer
Date: Wed,  2 Dec 2026 13:15:49 +0800
Organization: Usenet Network
Message-ID: <20261202051549.927-1-chenaibing@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1894737"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:A8kMbFMyekisY61514VrfyrYDHc= sha256:WH3PsraGYPdMSSafXPQ00SORqHxGXDNo31nDi5k3sB8=
	sha1:iWZPOttVKxzXxP0sIFeBMGTV6Kc= sha256:VuvIAYBTEw9JXr0m5tExTItcwCVdWnOBIPENSKYr6xE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id C46FC117517; Wed,  2 Dec 2026 08:16:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.751
X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 27cnQelLQROz;
	Wed,  2 Dec 2026 08:16:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375571-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A4A8C116018; Wed,  2 Dec 2026 08:16:07 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 4D0262D121; Wed,  2 Dec 2026 05:16:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796188559;
	b=yu69JJGYPA+FlZuh7BZu7SZ2mTX2x99hGNenymeDVceDB3yasJF4d0LWrMBmKcxfm/uB
	 8nO27nnf186Wifm6Ga/oeu4zYsB8oPpbgVZqlRU0IziiOxw4wVYUe4qBRw5GzhP+kfGYx
	 DaF7GfCzqcIGZgU5J+XCQpSdunK+O0asLISP52gdKKwRsZqO+dNhFMBieI49QLoVd5CWl
	 uVkTJyma4d3QXJihF8/sjOM8aQ9R+lVqPKxNlbV32JSwV4yfaiSt5ziQAorUr976wTJ4C
	 1rHqudHOpeE6lscLZ/0CSLEbZkHmFRLZiGx5C99wNy1XQ7LjBvDVKNbmhbM/wdeaShg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796188559;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=TL55QZhKDz53ofmE5cDYzXXG2gefOT5YO0VUbeQgV8c=;
	b=0gUfvHRVTV3aRTMJkftnYXwjuULySnyuLMuJWgs/dkDkFIwUb79tdW8t3rMsTwX15aEv
	 r+wSZCLMv6hnHDHSItrwa8KJ+AtWBAyk+tkrhV+0QNqQpOzet+/VTqeMYivs3bZ5M+h8K
	 VvTFhu1G90utAHtTbuEHf6z3jfg1SvYqkpNnV7AXFngnpOLhxk4DHxdfe/pNrcKMnfrW4
	 o5emdGjS7a0YrUTDnQc+uJ7nybusqHaCup+r48qxS2rVkZQvwxVQa+j7TJPXTX+MN5S6x
	 YoD10FJPY7MJ43qVdrZ457ehS4TIwL1De9skq73Src2BYPUANTpYEK2my209bHuf99w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=iNbi5u9X;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A0AF606A331;
	Wed,  2 Dec 2026 05:15:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=iNbi5u9X
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.139
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796188558;
	b=InhI7KKckRs9UUCsDy6Yo7hxa4HuNadkeNfUrrlU8BTi0swMQqFMdP0C2cBM/5IErzFr
	 UykCAB8xcLymdDrQyGL5/XlCO6SodH2WfHElcX4aHSrq3y8bEmcAcpgrK4xIsf1CfvAnu
	 7yd+yzFG5reM/iK1CMcrDDGsMa8BJYSnFD6E+Zt0p7kEiBCAiludRjhmnhi+u4z8SOwSj
	 xtgjNZpJpiI3KVH3muJ10popBubuZb9FOpoQqAEYxc8XdInat93YmU+eEKZFDr+c5LzmB
	 e/cHSb2Gfyp2jZA3/dMMmS3uW7B/nhNhvc+SAcwVdmMZnSrK7GpkaRbhbqautARUmqQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796188558;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=TL55QZhKDz53ofmE5cDYzXXG2gefOT5YO0VUbeQgV8c=;
	b=U6Osyd8/BO2IGSFFSZemCl0eDQxRA4zbYKErw9RpJqfr/ThwdBlmDiV7E0WZRGQiXuX3
	 RNGpWZQDjAN0AJ11uvk+I/DBBW5v/F9b9fTtLtcVCbkfmG8wBvFpaE+Ciifz0swbFKWyG
	 m/YDvZaYW8xnNHuWcMudGucRMlNUezLVDUDC62z75GtK6cHH9vkG8nr4+XW1ijWSTwc+c
	 o2becruQmOwxW3xHvKgVupJNtxzE3WSPV1+JBPorrFcrdzaCPXikx39FZta/eLppuYT52
	 zQOseMbcb6yhwy568ZPCy55KZBci+4hNwglVjk9cADBbZovNQrJuQEmXIr3swA0STgw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=iNbi5u9X;
	arc=none smtp.remote-ip=111.22.67.139
X-Received: from cmccmta6.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E510606A31A;
	Wed,  2 Dec 2026 05:15:54 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4E510606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=iNbi5u9XZCUYslYJfkFRm2C7cPPZ6x1TOXsOuoIfYT5GWUgfq3awCFNXIxD4RohI5CRGQG9lmAOts
	 6nDqc94zzI6RcSv66n0vCD9gYLhqBVN/Lr5lJx7SC6oeYOOfqxV3qYAfPwVT6RbCX67VmpC/Xm1Drn
	 VfbOVj5lGB8hG20I=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app01-12001 (RichMail) with SMTP id 2ee16b0fa983768-68a21;
	Wed, 02 Dec 2026 13:15:52 +0800 (CST)
X-RM-TRANSID: 2ee16b0fa983768-68a21
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from FHD-W7400297 (unknown[10.55.1.70])
	by rmsmtp-syy-appsvr01-12001 (RichMail) with SMTP id 2ee16b0fa9868e3-384ce;
	Wed, 02 Dec 2026 13:15:52 +0800 (CST)
X-RM-TRANSID: 2ee16b0fa9868e3-384ce
X-Cc: netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.50.1.windows.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list