🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #11450

[PATCH net-next] sfc: avoid truncating MCDI hwmon attribute names

#11450
From: xujiahao
Date: Thu, 05 Nov 2026 02:01
72 lines
11119 bytes
The name of each MCDI hwmon attribute is built in a 12-byte buffer as
prefix + 1-based per-type index + suffix, with prefixes up to "power"
and suffixes up to "_input".  With W=1 gcc reports:

  warning: 'snprintf' output may be truncated before the last format
  character [-Wformat-truncation=]

at mcdi_mon.c:457, :488 and :495, in both the sfc and the siena copy.

The same 12-byte field in struct efx_mcdi_mon_attribute, which receives
a strscpy() of the local buffer and backs the sysfs attribute name,
would also truncate silently once a sensor type has more than 9
instances: "power10_crit" already needs 13 bytes.

Enlarge both buffers to 24 bytes, enough for the longest possible name:
"power" + 10 digits + "_input" + NUL = 22 bytes.

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/all/202401100509.U4prhh6J-lkp@intel.com/
Signed-off-by: xujiahao <xujiahao@cmss.chinamobile.com>
---
 drivers/net/ethernet/sfc/mcdi_mon.c       | 4 ++--
 drivers/net/ethernet/sfc/siena/mcdi_mon.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/sfc/mcdi_mon.c b/drivers/net/ethernet/sfc/mcdi_mon.c
index e574f91f6..9700228df 100644
--- a/drivers/net/ethernet/sfc/mcdi_mon.c
+++ b/drivers/net/ethernet/sfc/mcdi_mon.c
@@ -138,7 +138,7 @@ struct efx_mcdi_mon_attribute {
 	unsigned int type;
 	enum efx_hwmon_type hwmon_type;
 	unsigned int limit_value;
-	char name[12];
+	char name[24];
 };
 
 static int efx_mcdi_mon_update(struct efx_nic *efx)
@@ -308,7 +308,7 @@ int efx_mcdi_mon_probe(struct efx_nic *efx)
 	MCDI_DECLARE_BUF(outbuf, MC_CMD_SENSOR_INFO_OUT_LENMAX);
 	unsigned int n_pages, n_sensors, n_attrs, page;
 	size_t outlen;
-	char name[12];
+	char name[24];
 	u32 mask;
 	int rc, i, j, type;
 
diff --git a/drivers/net/ethernet/sfc/siena/mcdi_mon.c b/drivers/net/ethernet/sfc/siena/mcdi_mon.c
index 0216a2a60..0037f603f 100644
--- a/drivers/net/ethernet/sfc/siena/mcdi_mon.c
+++ b/drivers/net/ethernet/sfc/siena/mcdi_mon.c
@@ -138,7 +138,7 @@ struct efx_mcdi_mon_attribute {
 	unsigned int type;
 	enum efx_hwmon_type hwmon_type;
 	unsigned int limit_value;
-	char name[12];
+	char name[24];
 };
 
 static int efx_mcdi_mon_update(struct efx_nic *efx)
@@ -308,7 +308,7 @@ int efx_siena_mcdi_mon_probe(struct efx_nic *efx)
 	MCDI_DECLARE_BUF(outbuf, MC_CMD_SENSOR_INFO_OUT_LENMAX);
 	unsigned int n_pages, n_sensors, n_attrs, page;
 	size_t outlen;
-	char name[12];
+	char name[24];
 	u32 mask;
 	int rc, i, j, type;
 
-- 
2.43.0
Technical Details
Message-ID: <20261105020115.278-1-xujiahao@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357029-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357029-linux-kernel-netdev=dewy.ru
From: xujiahao@cmss.chinamobile.com (xujiahao)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next] sfc: avoid truncating MCDI hwmon attribute names
Date: Thu,  5 Nov 2026 10:01:15 +0800
Organization: Usenet Network
Message-ID: <20261105020115.278-1-xujiahao@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3542940"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Zq6f7p26H9d8Xu2blfNpdS7YTJg= sha256:Ai71VqEdG2hr5tyyItRaMsLsbEuDKlUNYIL4PnOulvE=
	sha1:ZLWiF/SPNknMZUHtEv//E+A6vrA= sha256:eMVNL5AiK2NwUEbD3sd2HPmWOHwslFDPVRB1HK2I9Iw=
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 67CAB112E5C; Thu,  5 Nov 2026 05:28:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.75
X-Spam-Status: No, score=-2.75 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,
	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 HqOJ6SVNjXb2;
	Thu,  5 Nov 2026 05:28:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-357029-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id ADA3C112E51; Thu,  5 Nov 2026 05:28:17 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id EDDE6331D6; Thu,  5 Nov 2026 02:02:41 +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=1793844084;
	b=MKU7j9Su5o7qVcdwR1dM33a6GhsSZy77UttQzX7WDCJaAYUzraUHyzxIt4gt7ER5MSvP
	 xngba1Q/6wX9MJYPXujTFo01OqWo6XpFBxbYem88TPx1nBz8EOI5uwDTBM7S6+PmG17LX
	 UMqJmgIj0Mdl/7qpBEbEokLAXDV/+gQIVsYRRtuUFnRU496LDiKGkE46unGDlqAblvxId
	 KvDewKiZ3uHVRY+tIjX/aHqZUwuwThNVK5NdEsTbinxnW3Y6EAyGKNTFY5+MrexeaqgmD
	 j/EKZKe76+eznkSbtiHnsDroWb0JmxEXESHA+PA6ZkzXbF5tE1M9rzi5Lu/MErqAk0w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793844084;
	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=uP4WjeA3JswVZeabC7KpofLrQ7N3W1fMzpyXVDcHxUY=;
	b=AYVz7MOcfUuSmoxNOTH2rq3UTnkr07MQyX35orkJJtSwZlASTXVHnKgFfnBtCm+hKkZT
	 V2Hpiz3GX4BCDKLFgCWRuM2yEs2eAofprm0OvU9zQW2OHruxNPOJJe7zH88P6w+j7yfDX
	 dowN/RkZR06VIW1h2Lk2khB71FTISn4s0bOvFBn/oTvV7iXTkjbUk9wid88WsdKPpvnIs
	 kKg2sLI2dOqHxZDK5fM5q6AY4hRhwnIKUfhmWiYUDckS+fTc48tANMQGwrvKFYCqAteEF
	 bbhYoKJJf69VgTE9EaMl0/5PIlO7iB22451YwSrQFSmzAJDzuNzK1MLYMw+k04ukUJg==
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="N1Ch9/s4";
	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 ACC8E60A261C;
	Thu,  5 Nov 2026 02:01:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=N1Ch9/s4
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.135
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793844083;
	b=SVqlr3mtStc3VFe+Nrf+SzNKLqDEyyJfMq6J6A7R70KOTdsGCbPOb6U35pkU+RRA58kK
	 M5oLWkuWggKPXeZZo1Uh9mz4otJWYRZ+5Q2ZTwq6N+yQBd8+XIx6ce4N7TXhBjFnFK+t6
	 E35v+7Zl6+y3P4JjyBrWhXQ7gljFyN+MDr1xy748XbQ/YR1/lLjq5BKxUV4WGpmvMdgrI
	 BdecsOEV0+SOYbDW6PgUlAuPM3cS0B9wGyrqqwejFNl1IG6XcFLZUfUcGoOorloMdyWNN
	 RSYmpjRrUWQbzm+HeuAxIdYdv/dvfYeTYtxOaNkoE2f03HrsBddHSWBrgPdca0o0Nog==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793844083;
	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=uP4WjeA3JswVZeabC7KpofLrQ7N3W1fMzpyXVDcHxUY=;
	b=3DngnZOC6e7PYe7WFmsVCZfRbvJ8JQoqHw5ZFZWaTk0YM0CgONj0FzIThLqSLuDa5KII
	 4eQ4a3ZBcyvNTv+VhBFsTbGOX1K5nq5hXDZOef7BWNTZR/OvEIgc/HfAnlFJCpGUpEqKL
	 /woMyiIoDJpOMuYkFmfUeW25d1JcfVKfh2xEooeeyfd84puOcW8LT5U9fmLLsTvjVW19v
	 I1KyFKs8uiI9P2zK/rxjdNabQgAu1JudLUrBnvuW2D9GGfEDaiJMdALhbRNOcVYQzofza
	 5NvzGEnYg/Xsb6Hu4rhn2HJcR3/H4gQMaDRJxgbS2hXigaNNkadFUhNoK8VYgWgprWA==
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="N1Ch9/s4";
	arc=none smtp.remote-ip=111.22.67.135
X-Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [111.22.67.135])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1274D6082BE6;
	Thu,  5 Nov 2026 02:01:20 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1274D6082BE6
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=N1Ch9/s4VmCUB/eX/jTozk30Qq7MARDEWNwjti1dtOcwqQp9GORLUeKXGxr4JvokHG9QvJ5x9SeS3
	 ANMSLy4sxkgwtWZb5wJ2Xw/1DO7JOx65rB1yQqspHd7MLH8IP3jTqs/iP094NozjoRzzHAQkOPj/+7
	 s57zXRoraISrVKDg=
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-app03-12003 (RichMail) with SMTP id 2ee36aebe36e06b-6d430;
	Thu, 05 Nov 2026 10:01:18 +0800 (CST)
X-RM-TRANSID: 2ee36aebe36e06b-6d430
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from FHB-W5100256 (unknown[10.55.1.70])
	by rmsmtp-syy-appsvr09-12009 (RichMail) with SMTP id 2ee96aebe36bc9a-3523e;
	Thu, 05 Nov 2026 10:01:18 +0800 (CST)
X-RM-TRANSID: 2ee96aebe36bc9a-3523e
X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	linux-net-drivers@amd.com,
	linux-kernel@vger.kernel.org,
	xujiahao <xujiahao@cmss.chinamobile.com>,
	kernel test robot <lkp@intel.com>
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