LF-2090: spi: spi-fsl-qspi: fix dereference null return value issue
authorHan Xu <han.xu@nxp.com>
Thu, 22 Apr 2021 19:58:54 +0000 (14:58 -0500)
committerHan Xu <han.xu@nxp.com>
Wed, 5 May 2021 03:29:34 +0000 (22:29 -0500)
dereference null return value issue found by coverity, #18373, CWE-476.
Check if variable res is null first to fix the issue.

Signed-off-by: Han Xu <han.xu@nxp.com>
Reviewed-by: Frank Li <frank.li@nxp.com>
drivers/spi/spi-fsl-qspi.c

index 9851551..68434d3 100644 (file)
@@ -876,6 +876,10 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
                                        "QuadSPI-memory");
+       if (!res) {
+               ret = -ENOMEM;
+               goto err_put_ctrl;
+       }
        q->memmap_phy = res->start;
        /* Since there are 4 cs, map size required is 4 times ahb_buf_size */
        q->ahb_addr = devm_ioremap(dev, q->memmap_phy,