Re: [PATCH] usb: typec: ucsi: Only check the contract if there is a connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Lo! Thx for working out a fix this quickly!

I'm just the regression tracker, but I think there are a few minor
details to improve here.

On 17.12.21 15:03, Heikki Krogerus wrote:
> The driver must make sure there is an actual connection
> before checking details about the USB Power Delivery
> contract. Those details are not valid unless there is a
> connection.
> 
> This fixes NULL pointer dereference that is caused by an
> attempt to register bogus partner alternate mode that the
> firmware on some platform may report before the actual
> connection.
> 
> Fixes: 6cbe4b2d5a3f ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215117
BugLink? Is that a tag we really use? Then I'm unaware of it. Greg is
the expert and can likely clarify, but that line afaik needs to replaced
by this:

Link: https://bugzilla.kernel.org/show_bug.cgi?id=215117
Link:
https://lore.kernel.org/linux-usb/bug-215117-208809@xxxxxxxxxxxxxxxxxxxxxxxxx%2F/

Normally the last line would need a 's!linux-usb!r!', but seems the
kernel.org redirector doesn't work well in this particular case, so I
guess it's better this way than not at all :-/

The second line will also make the regression tracking bot automatically
close the issue (but I fear it might also fail due to the slash at the
end of the message-id :-/)

I think this line should be there as well:

Reported-by: Chris Hixon <linux-kernel-bugs@xxxxxxxxxxxxx>

But according to Documentation/process/5.Posting.rst you first need to
ask Chris if he's okay with that.

Ciao, Thorsten

#regzbot ^backmonitor:
https://lore.kernel.org/linux-usb/bug-215117-208809@xxxxxxxxxxxxxxxxxxxxxxxxx%2F/


> Signed-off-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
> ---
>  drivers/usb/typec/ucsi/ucsi.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 9d6b7e02d6efb..f0c2fa19f3e0f 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1164,7 +1164,9 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
>  		ret = 0;
>  	}
>  
> -	if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) == UCSI_CONSTAT_PWR_OPMODE_PD) {
> +	if (con->partner &&
> +	    UCSI_CONSTAT_PWR_OPMODE(con->status.flags) ==
> +	    UCSI_CONSTAT_PWR_OPMODE_PD) {
>  		ucsi_get_src_pdos(con);
>  		ucsi_check_altmodes(con);
>  	}
> 



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux