mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 14:42:08 +02:00
pds_core: ensure null-termination for firmware version strings
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: 45d76f4929 ("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>
This commit is contained in:
parent
985d4a55e6
commit
3d4432d34c
|
|
@ -122,12 +122,14 @@ int pdsc_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
|
|||
|
||||
listlen = min(fw_list.num_fw_slots, ARRAY_SIZE(fw_list.fw_names));
|
||||
for (i = 0; i < listlen; i++) {
|
||||
char *fw_ver = fw_list.fw_names[i].fw_version;
|
||||
|
||||
if (i < ARRAY_SIZE(fw_slotnames))
|
||||
strscpy(buf, fw_slotnames[i], sizeof(buf));
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "fw.slot_%d", i);
|
||||
err = devlink_info_version_stored_put(req, buf,
|
||||
fw_list.fw_names[i].fw_version);
|
||||
fw_ver[sizeof(fw_list.fw_names[i].fw_version) - 1] = '\0';
|
||||
err = devlink_info_version_stored_put(req, buf, fw_ver);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user