diff mbox series

[2/3] usb: typec: anx7411: fix passing a valid pointer to 'PTR_ERR'

Message ID 20220722081836.3380885-2-xji@analogixsemi.com
State New
Headers show
Series [1/3] usb: typec: anx7411: fix passing zero to 'PTR_ERR' | expand

Commit Message

Xin Ji July 22, 2022, 8:18 a.m. UTC
Fix anx7411_typec_register_altmode() warn: passing a valid pointer to
'PTR_ERR'.

Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
Signed-off-by: Xin Ji <xji@analogixsemi.com>
---
 drivers/usb/typec/anx7411.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Greg KH July 27, 2022, 12:28 p.m. UTC | #1
On Fri, Jul 22, 2022 at 04:18:35PM +0800, Xin Ji wrote:
> Fix anx7411_typec_register_altmode() warn: passing a valid pointer to
> 'PTR_ERR'.
> 
> Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
> Signed-off-by: Xin Ji <xji@analogixsemi.com>
> ---
>  drivers/usb/typec/anx7411.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
> index 7b45d7440a9d..dc86b6704cbd 100644
> --- a/drivers/usb/typec/anx7411.c
> +++ b/drivers/usb/typec/anx7411.c
> @@ -550,6 +550,7 @@ static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
>  {
>  	struct device *dev = &ctx->spi_client->dev;
>  	struct typec_altmode_desc desc;
> +	struct typec_altmode *alt;
>  	int i;
>  
>  	desc.svid = svid;
> @@ -566,14 +567,14 @@ static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
>  		return -ENOMEM;
>  	}
>  
> -	ctx->typec.amode[i] = typec_partner_register_altmode(ctx->typec.partner,
> -							     &desc);
> -	if (IS_ERR(ctx->typec.amode[i])) {
> +	alt = typec_partner_register_altmode(ctx->typec.partner, &desc);
> +	if (IS_ERR(alt)) {
>  		dev_err(dev, "failed to register altmode\n");
> -		ctx->typec.amode[i] = NULL;
> -		return PTR_ERR(ctx->typec.amode);
> +		return PTR_ERR(alt);
>  	}
>  
> +	ctx->typec.amode[i] = alt;
> +
>  	return 0;
>  }
>  
> -- 
> 2.25.1
> 

Does not apply to my tree :(
diff mbox series

Patch

diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
index 7b45d7440a9d..dc86b6704cbd 100644
--- a/drivers/usb/typec/anx7411.c
+++ b/drivers/usb/typec/anx7411.c
@@ -550,6 +550,7 @@  static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
 {
 	struct device *dev = &ctx->spi_client->dev;
 	struct typec_altmode_desc desc;
+	struct typec_altmode *alt;
 	int i;
 
 	desc.svid = svid;
@@ -566,14 +567,14 @@  static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
 		return -ENOMEM;
 	}
 
-	ctx->typec.amode[i] = typec_partner_register_altmode(ctx->typec.partner,
-							     &desc);
-	if (IS_ERR(ctx->typec.amode[i])) {
+	alt = typec_partner_register_altmode(ctx->typec.partner, &desc);
+	if (IS_ERR(alt)) {
 		dev_err(dev, "failed to register altmode\n");
-		ctx->typec.amode[i] = NULL;
-		return PTR_ERR(ctx->typec.amode);
+		return PTR_ERR(alt);
 	}
 
+	ctx->typec.amode[i] = alt;
+
 	return 0;
 }