drivers/net/ethernet/sfc/mcdi_mon.c | 4 ++-- drivers/net/ethernet/sfc/siena/mcdi_mon.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
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
© 2016 - 2026 Red Hat, Inc.