iio: adc: MCP3564: fix the static checker warning
authorMarius Cristea <marius.cristea@microchip.com>
Mon, 18 Sep 2023 07:56:33 +0000 (10:56 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 24 Sep 2023 13:23:55 +0000 (14:23 +0100)
The patch 33ec3e5fc1ea: "iio: adc: adding support for MCP3564 ADC"
from Aug 29, 2023 (linux-next), leads to the following Smatch static
checker warning:

        drivers/iio/adc/mcp3564.c:1426 mcp3564_probe()
        warn: address of NULL pointer 'indio_dev'

drivers/iio/adc/mcp3564.c
    1421         struct iio_dev *indio_dev;
    1422         struct mcp3564_state *adc;
    1423
    1424         indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
    1425         if (!indio_dev) {
--> 1426                 dev_err_probe(&indio_dev->dev, PTR_ERR(indio_dev),
                                       ^^^^^^^^^^^^^^^

Fixes: 33ec3e5fc1ea (iio: adc: adding support for MCP3564 ADC)
Signed-off-by: Marius Cristea <marius.cristea@microchip.com>
Link: https://lore.kernel.org/r/20230918075633.1884-1-marius.cristea@microchip.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/mcp3564.c

index 64145f4ae55c9630742d2fd7d926933e1d8303a5..9ede1a5d5d7bbc5fb683a5c613220dc11598205c 100644 (file)
@@ -1422,11 +1422,8 @@ static int mcp3564_probe(struct spi_device *spi)
        struct mcp3564_state *adc;
 
        indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
-       if (!indio_dev) {
-               dev_err_probe(&indio_dev->dev, PTR_ERR(indio_dev),
-                             "Can't allocate iio device\n");
+       if (!indio_dev)
                return -ENOMEM;
-       }
 
        adc = iio_priv(indio_dev);
        adc->spi = spi;