diff mbox series

[-next] usb: typec: tps6598x: Fix return value check in tps6598x_probe()

Message ID 20210308094841.3587751-1-weiyongjun1@huawei.com
State New
Headers show
Series [-next] usb: typec: tps6598x: Fix return value check in tps6598x_probe() | expand

Commit Message

Wei Yongjun March 8, 2021, 9:48 a.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

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")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/usb/typec/tps6598x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Heikki Krogerus March 8, 2021, 11:04 a.m. UTC | #1
On Mon, Mar 08, 2021 at 09:48:41AM +0000, 'Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> 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")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tps6598x.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
> index a4ec8e56c2b9..2c4ab90e16e7 100644
> --- a/drivers/usb/typec/tps6598x.c
> +++ b/drivers/usb/typec/tps6598x.c
> @@ -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,
diff mbox series

Patch

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index a4ec8e56c2b9..2c4ab90e16e7 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -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)) {