Skip to contentSkip to conversation

iio: adc: MCP3564: fix the static checker warning

PATCH Applied [email protected] 2 participants 2 messages Sep 18, 2023 – Sep 24, 2023

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 iio: adc: MCP3564: fix the static checker warning

From: Marius Cristea <[email protected]>

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)
---
 drivers/iio/adc/mcp3564.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/mcp3564.c +1 -4
index 64145f4ae55c..9ede1a5d5d7b 100644
@@ -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;

base-commit: 22da192f43f7d302d02644efa192ba5a05d935c9

Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 18 lines · On Mon, 18 Sep 2023 10:56:33 +0300 <[email protected]> wrote:

From: Marius Cristea <[email protected]>

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),  
                                       ^^^^^^^^^^^^^^^
Quoted 2 lines
Fixes 33ec3e5fc1ea (iio: adc: adding support for MCP3564 ADC)

Applied to the togreg branch of iio.git as that's where this driver is at the moment.

Thanks,

Jonathan

Quoted 23 lines
---
 drivers/iio/adc/mcp3564.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/mcp3564.c +1 -4
index 64145f4ae55c..9ede1a5d5d7b 100644
@@ -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;

base-commit: 22da192f43f7d302d02644efa192ba5a05d935c9