]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net/mlx5e: Correct snprintf truncation handling for fw_version buffer used by represe...
authorRahul Rameshbabu <rrameshbabu@nvidia.com>
Tue, 21 Nov 2023 23:00:22 +0000 (15:00 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jan 2024 12:38:56 +0000 (12:38 +0000)
commit72b8de75b394af684f3ca762874d8e147d2ca64c
tree71d99e9242495198e1a7bdce8eb6a4d81cdd51c4
parent18b4a5e0c3f565571ac86d9a17de75ccf458e419
net/mlx5e: Correct snprintf truncation handling for fw_version buffer used by representors

[ Upstream commit b13559b76157de9d74f04d3ca0e49d69de3b5675 ]

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: 1b2bd0c0264f ("net/mlx5e: Check return value of snprintf writing to fw_version buffer for representors")
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c