Input: mxs-lradc - do a NULL check on iores
authorFabio Estevam <fabio.estevam@nxp.com>
Mon, 14 Aug 2017 17:26:27 +0000 (10:26 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 15 Aug 2017 03:23:46 +0000 (20:23 -0700)
platform_get_resource() may fail, so we should better do a NULL check
and return error on failure.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/mxs-lradc-ts.c

index 58c016cd68098dbd54b7c3a56e5f62e06ed03211..71bf493e8b58d9ff666c82c375e45b7d45add6ae 100644 (file)
@@ -630,6 +630,8 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
        spin_lock_init(&ts->lock);
 
        iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!iores)
+               return -EINVAL;
        ts->base = devm_ioremap(dev, iores->start, resource_size(iores));
        if (IS_ERR(ts->base))
                return PTR_ERR(ts->base);