Linux IIO development
 help / color / mirror / Atom feed
* [bug report] iio: adc: adding support for MCP3564 ADC
@ 2023-09-14 10:01 Dan Carpenter
  2023-09-14 11:29 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-09-14 10:01 UTC (permalink / raw)
  To: marius.cristea; +Cc: linux-iio

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-15 15:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14 10:01 [bug report] iio: adc: adding support for MCP3564 ADC Dan Carpenter
2023-09-14 11:29 ` Dan Carpenter
2023-09-14 13:19   ` Marius.Cristea
2023-09-14 13:29     ` Dan Carpenter
2023-09-15 15:40       ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox