Skip to content

Commit f245312

Browse files
Binary-Eatergregkh
authored andcommitted
net/mlx5e: Correct snprintf truncation handling for fw_version buffer used by representors
[ Upstream commit b13559b ] snprintf returns the length of the formatted string, excluding the trailing null, without accounting for truncation. This means that is the return value is greater than or equal to the size parameter, the fw_version string was truncated. Link: https://docs.kernel.org/core-api/kernel-api.html#c.snprintf Fixes: 1b2bd0c ("net/mlx5e: Check return value of snprintf writing to fw_version buffer for representors") Signed-off-by: Rahul Rameshbabu <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent e8ba688 commit f245312

File tree

1 file changed

+1
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+1
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void mlx5e_rep_get_drvinfo(struct net_device *dev,
6868
count = snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
6969
"%d.%d.%04d (%.16s)", fw_rev_maj(mdev),
7070
fw_rev_min(mdev), fw_rev_sub(mdev), mdev->board_id);
71-
if (count == sizeof(drvinfo->fw_version))
71+
if (count >= sizeof(drvinfo->fw_version))
7272
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
7373
"%d.%d.%04d", fw_rev_maj(mdev),
7474
fw_rev_min(mdev), fw_rev_sub(mdev));

0 commit comments

Comments
 (0)