Skip to content

Commit

Permalink
platform: msm_shared: Check for null pointer in hw_platform
Browse files Browse the repository at this point in the history
Prevents lk2nd from crashing if hw_platform is not out of bounds for the
array but undefined.

Original CLO commit https://git.codelinaro.org/clo/la/kernel/lk/-/commit/7b1b74235adfb981ece4f5a7d1a8f8edfa65c8e1

Fixes: 511e22a ("smem: Default to unknown platform if hardware id is out of range")

Signed-off-by: Felix Kaechele <felix@kaechele.ca>
  • Loading branch information
kaechele committed Mar 26, 2024
1 parent 75a9de8 commit c3e1bd1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion platform/msm_shared/smem.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ size_t smem_get_hw_platform_name(void *buf, uint32_t buf_size)
}

hw_id = board_hardware_id();
if (hw_id >= ARRAY_SIZE(hw_platform))
if (hw_id >= ARRAY_SIZE(hw_platform) || hw_platform[hw_id] == '\0')
hw_id = HW_PLATFORM_UNKNOWN;

if (buf_size < strlen(hw_platform[hw_id]) + 1)
Expand Down

0 comments on commit c3e1bd1

Please sign in to comment.