Re: [PATCH v3] usb: typec: bus: verify partner exists in typec_altmode_attention

From: Heikki Krogerus
Date: Mon Aug 14 2023 - 09:36:55 EST


On Fri, Aug 11, 2023 at 09:37:32PM +0000, RD Babiera wrote:
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 5a7d8cc04628..97b7b22e9cf1 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -1791,6 +1791,7 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,
> u32 p[PD_MAX_PAYLOAD];
> u32 response[8] = { };
> int i, rlen = 0;
> + int ret;
>
> for (i = 0; i < cnt; i++)
> p[i] = le32_to_cpu(payload[i]);
> @@ -1877,7 +1878,9 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,
> }
> break;
> case ADEV_ATTENTION:
> - typec_altmode_attention(adev, p[1]);
> + ret = typec_altmode_attention(adev, p[1]);
> + if (ret)
> + tcpm_log(port, "typec_altmode_attention NULL port partner altmode");

I don't think you need that ret variable:

if (typec_altmode_attention(adev, p[1]))
tcpm_log(port, "typec_altmode_attention NULL port partner altmode");

> break;
> }
> }

thanks,

--
heikki