Skip to content

Commit 2ca8ea7

Browse files
nprao1opsiff
authored andcommitted
pds_core: ensure null-termination for firmware version strings
[ Upstream commit 3d4432d34c1992701289cbe12df9fd024f315998 ] The driver passes fw_version directly to devlink_info_version_stored_put() without ensuring null-termination. While current firmware null-terminates these strings, the driver should not rely on this behavior. Add explicit null-termination to prevent potential issues if firmware behavior changes. Fixes: 45d76f4 ("pds_core: set up device and adminq") Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com> Link: https://patch.msgid.link/20260520205842.1486718-1-nikhil.rao@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 8129611d4ede5c4b36a6b2649db140826fa0e569) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent a65d3a1 commit 2ca8ea7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/net/ethernet/amd/pds_core/devlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ int pdsc_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
121121

122122
listlen = min(fw_list.num_fw_slots, ARRAY_SIZE(fw_list.fw_names));
123123
for (i = 0; i < listlen; i++) {
124+
char *fw_ver = fw_list.fw_names[i].fw_version;
125+
124126
if (i < ARRAY_SIZE(fw_slotnames))
125127
strscpy(buf, fw_slotnames[i], sizeof(buf));
126128
else
127129
snprintf(buf, sizeof(buf), "fw.slot_%d", i);
128-
err = devlink_info_version_stored_put(req, buf,
129-
fw_list.fw_names[i].fw_version);
130+
fw_ver[sizeof(fw_list.fw_names[i].fw_version) - 1] = '\0';
131+
err = devlink_info_version_stored_put(req, buf, fw_ver);
130132
if (err)
131133
return err;
132134
}

0 commit comments

Comments
 (0)