Messages in this thread Patch in this message | | | From | Shailendra Verma <> | Subject | [PATCH] Bus - Fix possible NULL derefrence. | Date | Fri, 27 Jan 2017 16:45:25 +0530 |
| |
of_match_device could return NULL, and so can cause a NULL pointer dereference later.
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com> --- drivers/bus/imx-weim.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 4bd361d..5e26f44 100644 --- a/drivers/bus/imx-weim.c +++ b/drivers/bus/imx-weim.c @@ -138,12 +138,19 @@ static int __init weim_timing_setup(struct device_node *np, void __iomem *base, static int __init weim_parse_dt(struct platform_device *pdev, void __iomem *base) { - const struct of_device_id *of_id = of_match_device(weim_id_table, - &pdev->dev); - const struct imx_weim_devtype *devtype = of_id->data; + const struct of_device_id *of_id; + const struct imx_weim_devtype *devtype; struct device_node *child; int ret, have_child = 0;
+ of_id = of_match_device(weim_id_table, &pdev->dev); + if (!of_id) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } + + devtype = of_id->data; + if (devtype == &imx50_weim_devtype) { ret = imx_weim_gpr_setup(pdev); if (ret) -- 1.7.9.5
| |