Skip to contentSkip to conversation

usb: typec: tps6598x: Fix return value check in tps6598x_probe()

PATCH In review 'Wei Yongjun 2 participants 2 messages Mar 8, 2021

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

PATCH 1/1 usb: typec: tps6598x: Fix return value check in tps6598x_probe()

From: Wei Yongjun <[email protected]>

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

Fixes 18a6c866bb19 ("usb: typec: tps6598x: Add USB role switching logic")
---
 drivers/usb/typec/tps6598x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/tps6598x.c +2 -2
index a4ec8e56c2b9..2c4ab90e16e7 100644
@@ -629,8 +629,8 @@ static int tps6598x_probe(struct i2c_client *client)
 		return ret;
 
 	fwnode = device_get_named_child_node(&client->dev, "connector");
-	if (IS_ERR(fwnode))
-		return PTR_ERR(fwnode);
+	if (!fwnode)
+		return -ENODEV;
 
 	tps->role_sw = fwnode_usb_role_switch_get(fwnode);
 	if (IS_ERR(tps->role_sw)) {
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

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

Fixes 18a6c866bb19 ("usb: typec: tps6598x: Add USB role switching logic")
Quoted 9 lines
---
 drivers/usb/typec/tps6598x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/tps6598x.c +0 -0
index a4ec8e56c2b9..2c4ab90e16e7 100644

drivers/usb/typec/tps6598x.c static int tps6598x_probe(struct i2c_client *client) · line 636

Quoted 10 lines
drivers/usb/typec/tps6598x.c +2 -2
@@ -629,8 +629,8 @@ static int tps6598x_probe(struct i2c_client *client)
 		return ret;
 
 	fwnode = device_get_named_child_node(&client->dev, "connector");
-	if (IS_ERR(fwnode))
-		return PTR_ERR(fwnode);
+	if (!fwnode)
+		return -ENODEV;
 
 	tps->role_sw = fwnode_usb_role_switch_get(fwnode);
 	if (IS_ERR(tps->role_sw)) {

thanks,

Signature · 1 line
heikki