🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26847

[PATCH net-next v2 2/2] cxgb4: use scnprintf() for fw_version

#26847
From: Aibing Chen
Date: Fri, 04 Dec 2026 09:48
42 lines
10409 bytes
get_drvinfo() formats the firmware and TP revisions into
info->fw_version, a fixed ETHTOOL_FWVERS_LEN (32) byte field of the
ethtool_drvinfo UAPI structure:

  snprintf(info->fw_version, sizeof(info->fw_version),
           "%u.%u.%u.%u, TP %u.%u.%u.%u", ...);

The eight values are u8, so the format can produce up to 35 bytes; gcc
reports it in a W=1 build and CONFIG_WERROR turns it into a build
failure:

  cxgb4_ethtool.c:209:52: error: '%u' directive output may be truncated
    writing between 1 and 3 bytes into a region of size between 0 and 14
    [-Werror=format-truncation=]

Use scnprintf(), which returns the number of bytes written, so the string
is bounded by the field and the intent is visible at the call site.  The
ethtool_drvinfo layout is part of the UAPI and cannot be enlarged.

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202604141419.a4vuNBN7-lkp@intel.com/
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 0092bc16f..bba9ca03e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -205,8 +205,8 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 	info->regdump_len = get_regs_len(dev);
 
 	if (adapter->params.fw_vers)
-		snprintf(info->fw_version, sizeof(info->fw_version),
-			 "%u.%u.%u.%u, TP %u.%u.%u.%u",
+		scnprintf(info->fw_version, sizeof(info->fw_version),
+			  "%u.%u.%u.%u, TP %u.%u.%u.%u",
 			 FW_HDR_FW_VER_MAJOR_G(adapter->params.fw_vers),
 			 FW_HDR_FW_VER_MINOR_G(adapter->params.fw_vers),
 			 FW_HDR_FW_VER_MICRO_G(adapter->params.fw_vers),
Technical Details
Message-ID: <20261204094816.116-2-chenaibing@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377223-linux-kernel-netdev=dewy.ru
References: <20261204094816.116-1-chenaibing@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377223-linux-kernel-netdev=dewy.ru
From: chenaibing@cmss.chinamobile.com (Aibing Chen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 2/2] cxgb4: use scnprintf() for fw_version
Date: Fri,  4 Dec 2026 17:48:16 +0800
Organization: Usenet Network
Message-ID: <20261204094816.116-2-chenaibing@cmss.chinamobile.com>
References: <20261204094816.116-1-chenaibing@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2729701"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Phj25AVVD7TNm0J8LG/DQfCqKsI= sha256:knBUEcqksgP7wQ3pTxxzTL1LYc3fdOhssSqAh5ub7oo=
	sha1:VHTVniDVMpmb8XLiePmv314Vdpc= sha256:MCYG3nT2rEbfetGdL7Gu/DrGkKoW9Djr4VM+i8g5fp4=
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 DA55B117B85; Fri,  4 Dec 2026 12:48:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.998
X-Spam-Status: No, score=-2.998 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.001, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=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 tfT66crtDiH2;
	Fri,  4 Dec 2026 12:48:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377223-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 885B1117B52; Fri,  4 Dec 2026 12:48:32 +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 C224B24AC2; Fri,  4 Dec 2026 09:48:30 +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=1796377710;
	b=RE3hBa5e/Z6CKdRCxNNPnjU4mJBPyPYuKJ620zvPeJeT3STJFD+oaq///G4uRJ81EirT
	 3OXpE92sxF0Tmndyd11M3L7eCMfcOpahK+rTSYzg0dSI6gx+rF1cAYOkMcCJg8GMgXIk2
	 +OwBSKaDKr27DRQ7DjEKHRGVzbfhnKTLpne80J5Yr0ltdP1AKHflE13jkOnJwRqcZZSmt
	 WB8Z58tVRrShBiqgPXd5qFfb5krX2PCjy/CrEmN0mQ3uos5A8HQDa8/hUv1sJ074sM1TV
	 6Xt4pRdAmrB73NzgRuMoIqhC6U7Zcm+NdiFAXgjoVgh3Z0HQfxsMdO467ckg49Z7/rA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796377710;
	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:
	 In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=DRITGC5He4D8cjOFdqNLxnXmnX+wyvPsgAeN6fcQ+PU=;
	b=WFUrz07sbqzXIwPz3pGr21JvFD5Yghwhh2wbPREUb8FPF4msyK4/30ywKKgooVFxtMLO
	 pdj1tsqB0QRyA9y4VygCJ3GzvpVeBin129ulMB1uo7JAOW21/JVmUJ56mMeZDnWsZJQ7X
	 iMdcj4OwpK/TC50vVgMwwhOq7elKY6HrnioFO6i6OBoXaYDXnD8xP4FZxgbAiqf+Dbfq+
	 /eHVq7f/MAJPc+bUB3BYwIQWVtBLnxzDVoweE5YI21lAcf6B5CkJJrHxfwMX0eCObg3rZ
	 e9cbvn3YwkhfiC4SeQRFzIc4GiYl9RGU9yOuqINvIm/kBut6EUkGvnACACEh90nvY5Q==
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=LZ4ScvOZ;
	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 97111606A337;
	Fri,  4 Dec 2026 09:48:30 +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=LZ4ScvOZ
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=1796377704;
	b=rKdCsJ9+pYZPmnzY+TdDt4A6WydStYmQjhtduKu3XJPE3HgCPXTt8ip8++L7WSl0jRpF
	 Sb8p2FVtZ3QiWvcdZuNNfmxsHXiNIO/4hOBR9jnjauiOj3KobGSR9Ad2rQe486fx41fVt
	 XcTGgbsrTelMMB+qhqtG03d3U1Z9QdccXMfPGTrcax2mnXePo0xOtOHfBp/O9kn2dPSdg
	 vw0LJUCvxAhPtsEenakFbSuT9TcdI3NNwvS6b4txdFzoPbW36iQ1F0B8GoT7D4Za2wCUq
	 MrWEDfhgd+alxz0gkYBvychRQ5q09Txc6mJBBV98hYUtxWMyW+mjQ+7HxIBP0V7rhGQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796377704;
	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:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=DRITGC5He4D8cjOFdqNLxnXmnX+wyvPsgAeN6fcQ+PU=;
	b=salNukfX6Il9KYMJ6rfR2pGOWjjZAlmeyiFm7BfshaDN6vo4jUO7tlyDcoTWym5oKJne
	 w6ci25H8dj5RkgV6S0dFi+TnLzSoJex0j+YQ7Alf+uUHI2W4L7PkgQM/ckyFAt9lnGoJp
	 EltJiWeWArf0DLj0ujmdViiY0EZmVmIKTziKJ7lJpqJrlVmj3knnEfiDBglQ7+UCeamSF
	 D62Jq2olJ/IE3hL6QZ8eAUhThAYVeM0mXkjxFwlnwNpUcH4+h6Df06rxeN3ZAwdULHh3u
	 hg4+NG1lfDqJGMwv10Z+eXYmQyedSbw61/3YEUBHX1vvQ5cNL1TBpJSopAHv4KmnjwQ==
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=LZ4ScvOZ;
	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 0AEB5606A322;
	Fri,  4 Dec 2026 09:48:22 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0AEB5606A322
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=LZ4ScvOZwLsT1PDOD9JPkn0XebwPE6F0+aSaQU+lDBqjaRPxMNXCWh6sH5ovdlD/3DDoPwNXVKwvb
	 1KXvsxuccbyZlQ5fg3DGP3z1hXIwh6SeHFOsAYi6TQcab83mmcuMlGt+0QWc4Uj+1ysRngQTMUtxgm
	 YOZpOR0NuVzEsziY=
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 2ee16b128c5c9a7-81f8b;
	Fri, 04 Dec 2026 17:48:19 +0800 (CST)
X-RM-TRANSID: 2ee16b128c5c9a7-81f8b
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from  (unknown[10.55.1.70])
	by rmsmtp-syy-appsvr01-12001 (RichMail) with SMTP id 2ee16b128c60479-947f2;
	Fri, 04 Dec 2026 17:48:19 +0800 (CST)
X-RM-TRANSID: 2ee16b128c60479-947f2
X-Cc: netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.50.1.windows.1
X-In-Reply-To: <20261204094816.116-1-chenaibing@cmss.chinamobile.com>
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