Skip to content
Snippets Groups Projects
Commit 3ea09c5c authored by Louis-Alexis Eyraud's avatar Louis-Alexis Eyraud
Browse files

Input: mtk-pmic-keys: Fix null pointer dereference when no compatible data


In mtk_pmic_keys_probe function, the of_match_device function is
called to retrieve the compatible platform device info but its return
data pointer is not checked. It can lead to a null pointer deference
later when accessing the data field, if of_match_device returned a null
pointer. So, add a pointer check after calling of_match_device function
and return an EINVAL error in null case.

Signed-off-by: default avatarLouis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
parent 49881b55
No related branches found
No related tags found
No related merge requests found
Pipeline #138278 canceled
...@@ -345,6 +345,9 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) ...@@ -345,6 +345,9 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
const struct of_device_id *of_id = const struct of_device_id *of_id =
of_match_device(of_mtk_pmic_keys_match_tbl, &pdev->dev); of_match_device(of_mtk_pmic_keys_match_tbl, &pdev->dev);
if (!of_id)
return -EINVAL;
keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL); keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL);
if (!keys) if (!keys)
return -ENOMEM; return -ENOMEM;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment