thermal: imx: Fix possible NULL dereference.
authorShailendra Verma <shailendra.v@samsung.com>
Mon, 30 Jan 2017 05:04:58 +0000 (10:34 +0530)
committerEduardo Valentin <edubezval@gmail.com>
Sun, 19 Feb 2017 01:27:36 +0000 (17:27 -0800)
of_device_get_match_data could return NULL, and so can cause
a NULL pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/imx_thermal.c

index 06912f0602b75ba1a7d801babc686f5305838b59..fb648a45754eeff4177b0257b657ed59c4fe7a10 100644 (file)
@@ -489,6 +489,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
        data->tempmon = map;
 
        data->socdata = of_device_get_match_data(&pdev->dev);
+       if (!data->socdata) {
+               dev_err(&pdev->dev, "no device match found\n");
+               return -ENODEV;
+       }
 
        /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */
        if (data->socdata->version == TEMPMON_IMX6SX) {