Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Aibing Chen
Wed, 02 Dec 2026 05:15
[PATCH net-next] net: prestera: size the firmware version buffer
Author: Aibing Chen
Date: Wed, 02 Dec 2026 05:15
Date: Wed, 02 Dec 2026 05:15
43 lines
10096 bytes
10096 bytes
prestera_dl_info_get() formats the firmware revision with
snprintf(buf, sizeof(buf), "%d.%d.%d",
sw->dev->fw_rev.maj, sw->dev->fw_rev.min,
sw->dev->fw_rev.sub);
into a 16 byte buffer. The three fields are u16, so each can print up to
five digits and the format can produce 18 bytes including the
terminator. gcc reports this in a W=1 build, and CONFIG_WERROR turns the
warning into a build failure:
drivers/net/ethernet/marvell/prestera/prestera_devlink.c:359:43: error:
'%d' directive output may be truncated writing between 1 and 5 bytes
into a region of size between 4 and 12 [-Werror=format-truncation=]
The values come from the device firmware and are small in practice, but
gcc analyses the full u16 range. Size the buffer for the widest string
the format allows, "65535.65535.65535", so that the reported version can
never be cut.
No functional change for the versions seen in practice.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202501110646.aGxZ97Ug-lkp@intel.com/
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
drivers/net/ethernet/marvell/prestera/prestera_devlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_devlink.c b/drivers/net/ethernet/marvell/prestera/prestera_devlink.c
index 33dea101b..d5a04a4bb 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_devlink.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_devlink.c
@@ -354,7 +354,7 @@ static int prestera_dl_info_get(struct devlink *dl,
struct netlink_ext_ack *extack)
{
struct prestera_switch *sw = devlink_priv(dl);
- char buf[16];
+ char buf[sizeof("65535.65535.65535")];
snprintf(buf, sizeof(buf), "%d.%d.%d",
sw->dev->fw_rev.maj,
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