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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 24 Jul 2023 10:18:50 -0400
From:   Alan Stern <stern@...land.harvard.edu>
To:     Stanley Chang <stanley_chang@...ltek.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Vinod Koul <vkoul@...nel.org>,
        Kishon Vijay Abraham I <kishon@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Conor Dooley <conor+dt@...nel.org>,
        Roy Luo <royluo@...gle.com>, Ray Chi <raychi@...gle.com>,
        Flavio Suligoi <f.suligoi@...m.it>,
        linux-phy@...ts.infradead.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org
Subject: Re: [PATCH v8 1/5] usb: phy: add usb phy notify port status API

On Mon, Jul 24, 2023 at 06:34:48PM +0800, Stanley Chang wrote:

> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -614,6 +614,30 @@ static int hub_ext_port_status(struct usb_hub *hub, int port1, int type,
>  		ret = 0;
>  	}
>  	mutex_unlock(&hub->status_mutex);
> +
> +	/*
> +	 * There is no need to lock status_mutex here, because status_mutex
> +	 * protects hub->status, and the phy driver only checks the port
> +	 * status without changing the status.
> +	 */
> +	if (!ret) {
> +		struct usb_device *hdev = hub->hdev;
> +
> +		/*
> +		 * Applies to roothub only. That is, when hdev->parent is
> +		 * empty. Only roothub will be notified of port state
> +		 * changes, since the USB PHY only cares about changes at
> +		 * the next level.
> +		 */
> +		if (hdev && !hdev->parent) {

hdev can never be NULL, so you don't need to test it.  Also, there 
is an is_root_hub() routine you can call here -- it's an inline defined 
in usb.h.  If you use that then you won't have to explain it in the 
comment.

To be fair, there are plenty of other places in the driver that test 
!hdev->parent (or !udev->parent) with no explanation.

Alan Stern

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ