Skip to content

Commit

Permalink
firmware: meson_sm: fix to avoid potential NULL pointer dereference
Browse files Browse the repository at this point in the history
commit f2ed165 upstream.

of_match_device() may fail and returns a NULL pointer.

Fix this by checking the return value of of_match_device.

Fixes: 8cde3c2 ("firmware: meson_sm: Rework driver as a proper platform driver")
Signed-off-by: Zhang Shurong <[email protected]>
Reviewed-by: Neil Armstrong <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Neil Armstrong <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ZhangShurong authored and gregkh committed Apr 13, 2024
1 parent 35a5acf commit fba9c24
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/firmware/meson/meson_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ static int __init meson_sm_probe(struct platform_device *pdev)
return -ENOMEM;

chip = of_match_device(meson_sm_ids, dev)->data;
if (!chip)
return -EINVAL;

if (chip->cmd_shmem_in_base) {
fw->sm_shmem_in_base = meson_sm_map_shmem(chip->cmd_shmem_in_base,
Expand Down

0 comments on commit fba9c24

Please sign in to comment.