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] [day] [month] [year] [list]
Message-ID: <0c611f376c4646bda5bae2b46261ecbc@realtek.com>
Date:   Tue, 25 Jul 2023 02:44:01 +0000
From:   Stanley Chang[昌育德] <stanley_chang@...ltek.com>
To:     Alan Stern <stern@...land.harvard.edu>
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" <linux-phy@...ts.infradead.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>
Subject: RE: [PATCH v8 1/5] usb: phy: add usb phy notify port status API

Hi Alan,

> > --- 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.
> 

Using is_root_hub() is a good choice.

Thanks,
Stanley

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ