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
[ Upstream commit f2ed165 ]

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 <zhang_shurong@foxmail.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/tencent_AA08AAA6C4F34D53ADCE962E188A879B8206@qq.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ZhangShurong authored and gregkh committed Sep 13, 2023
1 parent 2965015 commit bd3a6b6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/firmware/meson/meson_sm.c
Expand Up @@ -292,6 +292,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 bd3a6b6

Please sign in to comment.