Skip to contentSkip to conversation

platform/x86: surface3_power: Fix a NULL vs IS_ERR() check in probe

PATCH In review Dan Carpenter 2 participants 2 messages Apr 7, 2020 – Apr 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: surface3_power: Fix a NULL vs IS_ERR() check in probe

The i2c_acpi_new_device() function never returns NULL, it returns error pointers.

Fixes b1f81b496b0d ("platform/x86: surface3_power: MSHW0011 rev-eng implementation")
---
 drivers/platform/x86/surface3_power.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/surface3_power.c +2 -2
index 946ac2dc08ae..cc4f9cba6856 100644
@@ -522,8 +522,8 @@ static int mshw0011_probe(struct i2c_client *client)
 	strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
 
 	bat0 = i2c_acpi_new_device(dev, 1, &board_info);
-	if (!bat0)
-		return -ENOMEM;
+	if (IS_ERR(bat0))
+		return PTR_ERR(bat0);
 
 	data->bat0 = bat0;
 	i2c_set_clientdata(bat0, data);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 4 lines · Dan Carpenter

The i2c_acpi_new_device() function never returns NULL, it returns error pointers.

Pushed to my review and testing queue, thanks!

Quoted 24 lines
Fixes b1f81b496b0d ("platform/x86: surface3_power: MSHW0011 rev-eng implementation")
---
 drivers/platform/x86/surface3_power.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/surface3_power.c +2 -3
index 946ac2dc08ae..cc4f9cba6856 100644
@@ -522,8 +522,8 @@ static int mshw0011_probe(struct i2c_client *client)
        strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
 
        bat0 = i2c_acpi_new_device(dev, 1, &board_info);
-       if (!bat0)
-               return -ENOMEM;
+       if (IS_ERR(bat0))
+               return PTR_ERR(bat0);
 
        data->bat0 = bat0;
        i2c_set_clientdata(bat0, data);
--

2.25.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko