From: shailendra.v@samsung.com Date: Fri, 27 Jan 2017 11:17:48 +0000 (+0530) Subject: soc: mediatek: PMIC wrap: Fix possible NULL derefrence. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=58a823dd7b515827ed07adb268e1769b3c292586;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git soc: mediatek: PMIC wrap: Fix possible NULL derefrence. of_match_device could return NULL, and so can cause a NULL pointer dereference later. Signed-off-by: Shailendra Verma Signed-off-by: Matthias Brugger --- diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c index 285b434449a6..c80a04e1b2b1 100644 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c @@ -1117,6 +1117,11 @@ static int pwrap_probe(struct platform_device *pdev) const struct of_device_id *of_slave_id = NULL; struct resource *res; + if (!of_id) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } + if (pdev->dev.of_node->child) of_slave_id = of_match_node(of_slave_match_tbl, pdev->dev.of_node->child);