[bug report] iio: adc: adding support for MCP3564 ADC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Marius Cristea,

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
    1418 static int mcp3564_probe(struct spi_device *spi)
    1419 {
    1420         int ret;
    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),
                                       ^^^^^^^^^^^^^^^
This will crash and PTR_ERR(NULL) is useless.  Please could we just
delete this printk?  devm_iio_device_alloc() is going to print its own
error message.  (It doesn't print on every error path.  Like if we pass
something stupid instead of sizeof(*adc) then that looks like it might
not have a warning, but it's going to print a warning for everthing in
real life).

    1427                               "Can't allocate iio device\n");
    1428                 return -ENOMEM;
    1429         }
    1430 
    1431         adc = iio_priv(indio_dev);
    1432         adc->spi = spi;
    1433 

regards,
dan carpenter



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux