lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aR2BYQSfOZjV-PuX@kuha>
Date: Wed, 19 Nov 2025 10:39:45 +0200
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Hsin-Te Yuan <yuanhsinte@...omium.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: Monitor connector change before
 getting connector status

On Mon, Nov 17, 2025 at 05:31:43PM +0800, Hsin-Te Yuan wrote:
> Originally, the notification for connector change will be enabled after
> the first read of the connector status. Therefore, if the event happens
> during this window, it will be missing and make the status unsynced.
> 
> Enable the notification for connector change before getting the
> connector status to ensure the status is synced.
> 
> Signed-off-by: Hsin-Te Yuan <yuanhsinte@...omium.org>
> ---
>  drivers/usb/typec/ucsi/ucsi.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 3f568f790f39b0271667e80816270274b8dd3008..07290cd85b618b22cb989151079707dbe9f578a7 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1565,7 +1565,7 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
>  	struct typec_capability *cap = &con->typec_cap;
>  	enum typec_accessory *accessory = cap->accessory;
>  	enum usb_role u_role = USB_ROLE_NONE;
> -	u64 command;
> +	u64 command, ntfy;
>  	char *name;
>  	int ret;
>  
> @@ -1659,6 +1659,15 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
>  		goto out;
>  	}
>  
> +	/* Enable the notification for connector change before getting the connector status */
> +	ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR | UCSI_ENABLE_NTFY_CONNECTOR_CHANGE;
> +	command = UCSI_SET_NOTIFICATION_ENABLE | ntfy;
> +	ret = ucsi_send_command(ucsi, command, NULL, 0);
> +	if (ret < 0) {
> +		dev_warn(ucsi->dev, "con%d: failed to enable the notification for connector change\n",
> +			 con->num);
> +	}

You can't do this repeatedly with every port that is registered. That
will lead into other problems.

I think the proper way to fix this is to first register all the ports
(and their alt modes) without checking the status, then enable the
notification, and finally check the status for every port separately.

So separate the status checking part at the end of
ucsi_register_port() into a new function, and then call it for every
port right after all notications are enabled in ucsi_init().

thanks,

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ