Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by xujiahao
Thu, 05 Nov 2026 02:01
[PATCH net-next] sfc: avoid truncating MCDI hwmon attribute names
Author: xujiahao
Date: Thu, 05 Nov 2026 02:01
Date: Thu, 05 Nov 2026 02:01
72 lines
11119 bytes
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
Re: [PATCH net-next] sfc: avoid truncating MCDI hwmon attribute names
Author: patchwork-bot+netdevbpf
Date: Tue, 10 Nov 2026 21:40
Date: Tue, 10 Nov 2026 21:40
24 lines
8583 bytes
8583 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads