lkml.org 
[lkml]   [2020]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] Fix USB Type C hub crash in typec_altmode_update_active
On Sat, 25 Jul 2020, Zwane Mwaikambo wrote:

> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index d0c63afaf..30d0857e4 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -218,9 +218,12 @@ void ucsi_altmode_update_active(struct ucsi_connector *con)
> if (cur < UCSI_MAX_ALTMODES)
> altmode = typec_altmode_get_partner(con->port_altmode[cur]);
>
> - for (i = 0; con->partner_altmode[i]; i++)
> - typec_altmode_update_active(con->partner_altmode[i],
> - con->partner_altmode[i] == altmode);
> + for (i = 0; i < UCSI_MAX_ALTMODES; i++) {
> + if (con->partner_altmode[i]) {
> + typec_altmode_update_active(con->partner_altmode[i],
> + con->partner_altmode[i] == altmode);
> + }
> + }
> }
>
> static u8 ucsi_altmode_next_mode(struct typec_altmode **alt, u16 svid)
>

Previous patch had whitespace issues and i cleaned it up for coding style
reasons, patch is against 5.8.0-rc6

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index d0c63afaf..30e811fde 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -218,9 +218,10 @@ void ucsi_altmode_update_active(struct ucsi_connector *con)
if (cur < UCSI_MAX_ALTMODES)
altmode = typec_altmode_get_partner(con->port_altmode[cur]);

- for (i = 0; con->partner_altmode[i]; i++)
- typec_altmode_update_active(con->partner_altmode[i],
- con->partner_altmode[i] == altmode);
+ for (i = 0; i < UCSI_MAX_ALTMODES; i++)
+ if (con->partner_altmode[i])
+ typec_altmode_update_active(con->partner_altmode[i],
+ con->partner_altmode[i] == altmode);
}

static u8 ucsi_altmode_next_mode(struct typec_altmode **alt, u16 svid)
\
 
 \ /
  Last update: 2020-07-26 08:43    [W:0.028 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site