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]
Message-ID: <ZImE4L3YgABnCIsP@kuha.fi.intel.com>
Date:   Wed, 14 Jun 2023 12:14:08 +0300
From:   Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To:     Prashanth K <quic_prashk@...cinc.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        Matthias Brugger <matthias.bgg@...il.com>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7] usb: common: usb-conn-gpio: Set last role to unknown
 before initial detection

On Wed, May 31, 2023 at 08:11:14PM +0530, Prashanth K wrote:
> Currently if we bootup a device without cable connected, then
> usb-conn-gpio won't call set_role() since last_role is same as
> current role. This happens because during probe last_role gets
> initialised to zero.
> 
> To avoid this, added a new constant in enum usb_role, last_role
> is set to USB_ROLE_UNKNOWN before performing initial detection.
> 
> While at it, also handle default case for the usb_role switch
> in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid
> build warnings.
> 
> Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection detection driver")
> Signed-off-by: Prashanth K <quic_prashk@...cinc.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
> ---
> v7: Added default case in musb/jz4740.c & intel-xhci-usb-role-switch.c to
>     avoid build warnings.
> v6: Moved USB_ROLE_UNKNOWN towards the end of enum usb_role.
> v5: Update commit text to mention the changes made in cdns3 driver.
> v4: Added Reviewed-by tag.
> v3: Added a default case in drivers/usb/cdns3/core.c as pointed out by
>     the test robot.
> v2: Added USB_ROLE_UNKNWON to enum usb_role.
> 
>  drivers/usb/cdns3/core.c                       | 2 ++
>  drivers/usb/common/usb-conn-gpio.c             | 3 +++
>  drivers/usb/musb/jz4740.c                      | 2 ++
>  drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 ++
>  include/linux/usb/role.h                       | 1 +
>  5 files changed, 10 insertions(+)

Just to be clear to everybody, that USB_ROLE_UNKNOWN is not handled in
drivers/usb/roles/class.c, so this patch is broken.

But the whole approach is wrong. That USB_ROLE_UNKNOWN is clearly a
flag where the other values in enum usb_role are actual switch states.
So it does not belong there.

In general, adding globals states like that just in order to work
around issues in single drivers is never a good idea IMO.

thanks,

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ