* [PATCH net-next] sfc: avoid truncating MCDI hwmon attribute names
@ 2026-11-05 2:01 xujiahao
2026-11-10 21:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: xujiahao @ 2026-11-05 2:01 UTC (permalink / raw)
To: Edward Cree, netdev
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-net-drivers, linux-kernel, xujiahao,
kernel test robot
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] sfc: avoid truncating MCDI hwmon attribute names
2026-11-05 2:01 [PATCH net-next] sfc: avoid truncating MCDI hwmon attribute names xujiahao
@ 2026-11-10 21:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-10 21:40 UTC (permalink / raw)
To: xujiahao
Cc: ecree.xilinx, netdev, andrew+netdev, davem, edumazet, kuba,
pabeni, linux-net-drivers, linux-kernel, lkp
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 5 Nov 2026 10:01:15 +0800 you wrote:
> 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=]
>
> [...]
Here is the summary with links:
- [net-next] sfc: avoid truncating MCDI hwmon attribute names
https://git.kernel.org/netdev/net-next/c/97ced2c090bf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-10 21:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 2:01 [PATCH net-next] sfc: avoid truncating MCDI hwmon attribute names xujiahao
2026-11-10 21:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®