MLK-21520-1 spi: lpspi: add NULL check when probe device
authorClark Wang <xiaoning.wang@nxp.com>
Tue, 23 Apr 2019 07:11:58 +0000 (15:11 +0800)
committerClark Wang <xiaoning.wang@nxp.com>
Tue, 23 Apr 2019 08:58:05 +0000 (16:58 +0800)
Add a NULL check for device node and lpspi_platform_info when lpspi
device probe.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
drivers/spi/spi-fsl-lpspi.c

index 0c38d79..38a7a3b 100644 (file)
@@ -829,6 +829,11 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
        int i, ret, irq;
        u32 temp;
 
+       if (!np && !lpspi_platform_info) {
+               dev_err(&pdev->dev, "can't get the platform data\n");
+               return -EINVAL;
+       }
+
        if (of_property_read_bool((&pdev->dev)->of_node, "spi-slave"))
                controller = spi_alloc_slave(&pdev->dev,
                                        sizeof(struct fsl_lpspi_data));