* [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
* Re: [bug report] iio: adc: adding support for MCP3564 ADC
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
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-09-14 11:29 UTC (permalink / raw)
To: marius.cristea; +Cc: linux-iio
On Thu, Sep 14, 2023 at 01:01:02PM +0300, Dan Carpenter wrote:
> 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
Actually I think that dev_err_probe() has a check for this kind of bug
so it doesn't actually crash. The check is burried deep into the call
tree where it prints the name and if the address is < PAGE_SIZE it just
prints the device name as "(efault)". But it's still not ideal.
regads,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bug report] iio: adc: adding support for MCP3564 ADC
2023-09-14 11:29 ` Dan Carpenter
@ 2023-09-14 13:19 ` Marius.Cristea
2023-09-14 13:29 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Marius.Cristea @ 2023-09-14 13:19 UTC (permalink / raw)
To: dan.carpenter; +Cc: linux-iio
Hello Dan Carpenter,
Thank you for your feedback.
Indeed, it will not add more information in this case so sure I can
remove that line.
Please, tell me how it is best to procced next: submitting another
PATCH (V6) in this case, or to create a Fixes to the PATCH_V5?
Best Regards,
Marius
On Thu, 2023-09-14 at 14:29 +0300, Dan Carpenter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> On Thu, Sep 14, 2023 at 01:01:02PM +0300, Dan Carpenter wrote:
> > 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
>
> Actually I think that dev_err_probe() has a check for this kind of
> bug
> so it doesn't actually crash. The check is burried deep into the
> call
> tree where it prints the name and if the address is < PAGE_SIZE it
> just
> prints the device name as "(efault)". But it's still not ideal.
>
> regads,
> dan carpenter
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bug report] iio: adc: adding support for MCP3564 ADC
2023-09-14 13:19 ` Marius.Cristea
@ 2023-09-14 13:29 ` Dan Carpenter
2023-09-15 15:40 ` Jonathan Cameron
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-09-14 13:29 UTC (permalink / raw)
To: Marius.Cristea; +Cc: linux-iio
On Thu, Sep 14, 2023 at 01:19:33PM +0000, Marius.Cristea@microchip.com wrote:
> Hello Dan Carpenter,
>
>
> Thank you for your feedback.
> Indeed, it will not add more information in this case so sure I can
> remove that line.
>
> Please, tell me how it is best to procced next: submitting another
> PATCH (V6) in this case, or to create a Fixes to the PATCH_V5?
>
I believe that you should send a follow on patch instead of sending
another rev.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bug report] iio: adc: adding support for MCP3564 ADC
2023-09-14 13:29 ` Dan Carpenter
@ 2023-09-15 15:40 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2023-09-15 15:40 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Marius.Cristea, linux-iio
On Thu, 14 Sep 2023 16:29:26 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> On Thu, Sep 14, 2023 at 01:19:33PM +0000, Marius.Cristea@microchip.com wrote:
> > Hello Dan Carpenter,
> >
> >
> > Thank you for your feedback.
> > Indeed, it will not add more information in this case so sure I can
> > remove that line.
> >
> > Please, tell me how it is best to procced next: submitting another
> > PATCH (V6) in this case, or to create a Fixes to the PATCH_V5?
> >
>
> I believe that you should send a follow on patch instead of sending
> another rev.
>
> regards,
> dan carpenter
>
>
Yes - at this stage follow on patch preferred.
Jonathan
^ 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