MLK-12153: mtd: fsl-quadspi: fix the QSPI dereference null return value found by...
authorHan Xu <han.xu@nxp.com>
Thu, 7 Jan 2016 19:21:02 +0000 (13:21 -0600)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:49:41 +0000 (14:49 -0500)
check the return value to avoid the dereference null return value when
parsing device tree.

Signed-off-by: Han Xu <han.xu@nxp.com>
drivers/mtd/spi-nor/fsl-quadspi.c

index e3e476d..31b000e 100644 (file)
@@ -1081,6 +1081,10 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 
        /* find the resources */
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "QuadSPI");
+       if (!res) {
+               dev_err(dev, "QuadSPI get resource IORESOURCE_MEM failed\n");
+               return -ENODEV;
+       }
        q->iobase = devm_ioremap_resource(dev, res);
        if (IS_ERR(q->iobase))
                return PTR_ERR(q->iobase);
@@ -1088,6 +1092,11 @@ static int fsl_qspi_probe(struct platform_device *pdev)
        q->big_endian = of_property_read_bool(np, "big-endian");
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
                                        "QuadSPI-memory");
+       if (!res) {
+               dev_err(dev,
+                       "QuadSPI-memory get resource IORESOURCE_MEM failed\n");
+               return -ENODEV;
+       }
        if (!devm_request_mem_region(dev, res->start, resource_size(res),
                                     res->name)) {
                dev_err(dev, "can't request region for resource %pR\n", res);