Skip to content

Commit 3b87886

Browse files
author
Steven Price
committed
drm/panthor: Clean up FW version information display
Assigning a string to an array which is too small to include the NUL byte at the end causes a warning on some compilers. But this function also has some other oddities like the 'header' array which is only ever used within sizeof(). Tidy up the function by removing the 'header' array, allow the NUL byte to be present in git_sha_header, and calculate the length directly from git_sha_header. Reported-by: Will Deacon <[email protected]> Closes: https://lore.kernel.org/all/20250213154237.GA11897@willie-the-truck/ Fixes: 9d443de ("drm/panthor: Display FW version information") Signed-off-by: Steven Price <[email protected]> Acked-by: Will Deacon <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c63c3bf commit 3b87886

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/gpu/drm/panthor/panthor_fw.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ static int panthor_fw_read_build_info(struct panthor_device *ptdev,
636636
u32 ehdr)
637637
{
638638
struct panthor_fw_build_info_hdr hdr;
639-
char header[9];
640-
const char git_sha_header[sizeof(header)] = "git_sha: ";
639+
static const char git_sha_header[] = "git_sha: ";
640+
const int header_len = sizeof(git_sha_header) - 1;
641641
int ret;
642642

643643
ret = panthor_fw_binary_iter_read(ptdev, iter, &hdr, sizeof(hdr));
@@ -651,8 +651,7 @@ static int panthor_fw_read_build_info(struct panthor_device *ptdev,
651651
return 0;
652652
}
653653

654-
if (memcmp(git_sha_header, fw->data + hdr.meta_start,
655-
sizeof(git_sha_header))) {
654+
if (memcmp(git_sha_header, fw->data + hdr.meta_start, header_len)) {
656655
/* Not the expected header, this isn't metadata we understand */
657656
return 0;
658657
}
@@ -665,7 +664,7 @@ static int panthor_fw_read_build_info(struct panthor_device *ptdev,
665664
}
666665

667666
drm_info(&ptdev->base, "Firmware git sha: %s\n",
668-
fw->data + hdr.meta_start + sizeof(git_sha_header));
667+
fw->data + hdr.meta_start + header_len);
669668

670669
return 0;
671670
}

0 commit comments

Comments
 (0)