Skip to contentSkip to conversation

iio: adc: max9611: Fix return value check in max9611_probe()

PATCH In review Wei Yongjun 2 participants 2 messages Apr 27, 2017 – Apr 30, 2017 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: max9611: Fix return value check in max9611_probe()

From: Wei Yongjun <[email protected]>

In case of error, the function devm_iio_device_alloc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

---
 drivers/iio/adc/max9611.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/max9611.c +2 -2
index ec82106..dc3869b 100644
@@ -536,8 +536,8 @@ static int max9611_probe(struct i2c_client *client,
 	int ret;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611));
-	if (IS_ERR(indio_dev))
-		return PTR_ERR(indio_dev);
+	if (!indio_dev)
+		return -ENOMEM;
 
 	i2c_set_clientdata(client, indio_dev);
maintainer
#1 lore raw
Quoted 7 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function devm_iio_device_alloc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Good catch. Dan Carpenter also sent the same fix though and I've already applied that one.

Thanks,

Jonathan

Quoted 19 lines
---
 drivers/iio/adc/max9611.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/max9611.c +2 -2
index ec82106..dc3869b 100644
@@ -536,8 +536,8 @@ static int max9611_probe(struct i2c_client *client,
 	int ret;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611));
-	if (IS_ERR(indio_dev))
-		return PTR_ERR(indio_dev);
+	if (!indio_dev)
+		return -ENOMEM;
 
 	i2c_set_clientdata(client, indio_dev);