Skip to contentSkip to conversation

usb: typec: fix an IS_ERR() vs NULL bug in hd3ss3220_probe()

PATCH Superseded Dan Carpenter 2 participants 4 messages Oct 11, 2019 – Oct 14, 2019

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

PATCH 1/1 usb: typec: fix an IS_ERR() vs NULL bug in hd3ss3220_probe()

The device_get_named_child_node() function doesn't return error pointers, it returns NULL on error.

Fixes 1c48c759ef4b ("usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller")
---
 drivers/usb/typec/hd3ss3220.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/hd3ss3220.c +2 -2
index 9715600aeb04..37b08f57aac4 100644
@@ -172,8 +172,8 @@ static int hd3ss3220_probe(struct i2c_client *client,
 	hd3ss3220_set_source_pref(hd3ss3220,
 				  HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_DEFAULT);
 	connector = device_get_named_child_node(hd3ss3220->dev, "connector");
-	if (IS_ERR(connector))
-		return PTR_ERR(connector);
+	if (!connector)
+		return -EIO;
 
 	hd3ss3220->role_sw = fwnode_usb_role_switch_get(connector);
 	fwnode_handle_put(connector);
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 14 lines · Dan Carpenter

The device_get_named_child_node() function doesn't return error pointers, it returns NULL on error.

Fixes 1c48c759ef4b ("usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller")
---
 drivers/usb/typec/hd3ss3220.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/hd3ss3220.c +0 -0
index 9715600aeb04..37b08f57aac4 100644

drivers/usb/typec/hd3ss3220.c static int hd3ss3220_probe(struct i2c_client *client, · line 176

Quoted 7 lines
drivers/usb/typec/hd3ss3220.c +2 -2
@@ -172,8 +172,8 @@ static int hd3ss3220_probe(struct i2c_client *client,
 	hd3ss3220_set_source_pref(hd3ss3220,
 				  HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_DEFAULT);
 	connector = device_get_named_child_node(hd3ss3220->dev, "connector");
-	if (IS_ERR(connector))
-		return PTR_ERR(connector);
+	if (!connector)
+		return -EIO;

I think the driver should return -ENODEV if there is no node for the connector.

thanks,

Signature · 1 line
heikki
#2 lore raw

PATCH v2 1/1 usb: typec: fix an IS_ERR() vs NULL bug in hd3ss3220_probe()

The device_get_named_child_node() function doesn't return error pointers, it returns NULL on error.

Fixes 1c48c759ef4b ("usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller")

---
v2: remove -ENODEV instead of -EIO

 drivers/usb/typec/hd3ss3220.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/hd3ss3220.c +2 -2
index 9715600aeb04..8afaf5768a17 100644
@@ -172,8 +172,8 @@ static int hd3ss3220_probe(struct i2c_client *client,
 	hd3ss3220_set_source_pref(hd3ss3220,
 				  HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_DEFAULT);
 	connector = device_get_named_child_node(hd3ss3220->dev, "connector");
-	if (IS_ERR(connector))
-		return PTR_ERR(connector);
+	if (!connector)
+		return -ENODEV;
 
 	hd3ss3220->role_sw = fwnode_usb_role_switch_get(connector);
 	fwnode_handle_put(connector);
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 1/1
#3 lore raw
Quoted 5 lines · Dan Carpenter

The device_get_named_child_node() function doesn't return error pointers, it returns NULL on error.

Fixes 1c48c759ef4b ("usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller")
Quoted 23 lines

---
v2: remove -ENODEV instead of -EIO

 drivers/usb/typec/hd3ss3220.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/hd3ss3220.c +2 -2
index 9715600aeb04..8afaf5768a17 100644
@@ -172,8 +172,8 @@ static int hd3ss3220_probe(struct i2c_client *client,
 	hd3ss3220_set_source_pref(hd3ss3220,
 				  HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_DEFAULT);
 	connector = device_get_named_child_node(hd3ss3220->dev, "connector");
-	if (IS_ERR(connector))
-		return PTR_ERR(connector);
+	if (!connector)
+		return -ENODEV;
 
 	hd3ss3220->role_sw = fwnode_usb_role_switch_get(connector);
 	fwnode_handle_put(connector);
Signature · 1 line
2.20.1

thanks,

Signature · 1 line
heikki