Commit a42264eb authored by Simon Horman's avatar Simon Horman Committed by Wen Zhiwei
Browse files

bnxt_en: Extend maximum length of version string by 1 byte

stable inclusion
from stable-v6.6.55
commit 0d6255e512b3a3c45febd7c027062fbd9366013e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB0MX4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0d6255e512b3a3c45febd7c027062fbd9366013e



--------------------------------

[ Upstream commit ffff7ee843c351ce71d6e0d52f0f20bea35e18c9 ]

This corrects an out-by-one error in the maximum length of the package
version string. The size argument of snprintf includes space for the
trailing '\0' byte, so there is no need to allow extra space for it by
reducing the value of the size argument by 1.

Found by inspection.
Compile tested only.

Signed-off-by: default avatarSimon Horman <horms@kernel.org>
Reviewed-by: default avatarMichael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20240813-bnxt-str-v2-1-872050a157e7@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 059d514a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3021,7 +3021,7 @@ static void bnxt_get_pkgver(struct net_device *dev)

	if (!bnxt_get_pkginfo(dev, buf, sizeof(buf))) {
		len = strlen(bp->fw_ver_str);
		snprintf(bp->fw_ver_str + len, FW_VER_STR_LEN - len - 1,
		snprintf(bp->fw_ver_str + len, FW_VER_STR_LEN - len,
			 "/pkg %s", buf);
	}
}