Skip to content

Commit 8c817eb

Browse files
emuslnkuba-moo
authored andcommitted
pds_core: limit loop over fw name list
Add an array size limit to the for-loop to be sure we don't try to reference a fw_version string off the end of the fw info names array. We know that our firmware only has a limited number of firmware slot names, but we shouldn't leave this unchecked. Fixes: 45d76f4 ("pds_core: set up device and adminq") Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Brett Creeley <brett.creeley@amd.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20250103195147.7408-1-shannon.nelson@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 8ce4f28 commit 8c817eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int pdsc_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
118118
if (err && err != -EIO)
119119
return err;
120120

121-
listlen = fw_list.num_fw_slots;
121+
listlen = min(fw_list.num_fw_slots, ARRAY_SIZE(fw_list.fw_names));
122122
for (i = 0; i < listlen; i++) {
123123
if (i < ARRAY_SIZE(fw_slotnames))
124124
strscpy(buf, fw_slotnames[i], sizeof(buf));

0 commit comments

Comments
 (0)