diff mbox series

usb: typec: Check for ops->exit instead of ops->enter in altmode_exit

Message ID 20221114165924.33487-1-sven@svenpeter.dev (mailing list archive)
State Accepted
Commit b6ddd180e3d9f92c1e482b3cdeec7dda086b1341
Headers show
Series usb: typec: Check for ops->exit instead of ops->enter in altmode_exit | expand

Commit Message

Sven Peter Nov. 14, 2022, 4:59 p.m. UTC
typec_altmode_exit checks if ops->enter is not NULL but then calls
ops->exit a few lines below. Fix that and check for the function
pointer it's about to call instead.

Fixes: 8a37d87d72f0 ("usb: typec: Bus type for alternate modes")
Signed-off-by: Sven Peter <sven@svenpeter.dev>
---
 drivers/usb/typec/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heikki Krogerus Nov. 16, 2022, 12:05 p.m. UTC | #1
On Mon, Nov 14, 2022 at 05:59:24PM +0100, Sven Peter wrote:
> typec_altmode_exit checks if ops->enter is not NULL but then calls
> ops->exit a few lines below. Fix that and check for the function
> pointer it's about to call instead.
> 
> Fixes: 8a37d87d72f0 ("usb: typec: Bus type for alternate modes")
> Signed-off-by: Sven Peter <sven@svenpeter.dev>

No Cc: stable@...?

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

> ---
>  drivers/usb/typec/bus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
> index 26ea2fdec17d..31c2a3130cad 100644
> --- a/drivers/usb/typec/bus.c
> +++ b/drivers/usb/typec/bus.c
> @@ -134,7 +134,7 @@ int typec_altmode_exit(struct typec_altmode *adev)
>  	if (!adev || !adev->active)
>  		return 0;
>  
> -	if (!pdev->ops || !pdev->ops->enter)
> +	if (!pdev->ops || !pdev->ops->exit)
>  		return -EOPNOTSUPP;
>  
>  	/* Moving to USB Safe State */

thanks,
diff mbox series

Patch

diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
index 26ea2fdec17d..31c2a3130cad 100644
--- a/drivers/usb/typec/bus.c
+++ b/drivers/usb/typec/bus.c
@@ -134,7 +134,7 @@  int typec_altmode_exit(struct typec_altmode *adev)
 	if (!adev || !adev->active)
 		return 0;
 
-	if (!pdev->ops || !pdev->ops->enter)
+	if (!pdev->ops || !pdev->ops->exit)
 		return -EOPNOTSUPP;
 
 	/* Moving to USB Safe State */