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: <Pine.LNX.4.44L0.2002251028030.1485-100000@iolanthe.rowland.org>
Date:   Tue, 25 Feb 2020 10:32:32 -0500 (EST)
From:   Alan Stern <stern@...land.harvard.edu>
To:     Eugeniu Rosca <erosca@...adit-jv.com>
cc:     linux-usb@...r.kernel.org, <linux-renesas-soc@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
        "Lee, Chiasheng" <chiasheng.lee@...el.com>,
        Mathieu Malaterre <malat@...ian.org>,
        Kai-Heng Feng <kai.heng.feng@...onical.com>,
        Hardik Gajjar <hgajjar@...adit-jv.com>,
        <scan-admin@...erity.com>
Subject: Re: [PATCH] usb: hub: Fix unhandled return value of usb_autopm_get_interface()

On Tue, 25 Feb 2020, Eugeniu Rosca wrote:

> Address below Coverity complaint (Feb 25, 2020, 8:06 AM CET):
> 
> *** CID 1458999:  Error handling issues  (CHECKED_RETURN)
> /drivers/usb/core/hub.c: 1869 in hub_probe()
> 1863
> 1864            if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND)
> 1865                    hub->quirk_check_port_auto_suspend = 1;
> 1866
> 1867            if (id->driver_info & HUB_QUIRK_DISABLE_AUTOSUSPEND) {
> 1868                    hub->quirk_disable_autosuspend = 1;
>  >>>     CID 1458999:  Error handling issues  (CHECKED_RETURN)
>  >>>     Calling "usb_autopm_get_interface" without checking return value (as is done elsewhere 97 out of 111 times).
> 1869                    usb_autopm_get_interface(intf);
> 1870            }
> 1871
> 1872            if (hub_configure(hub, &desc->endpoint[0].desc) >= 0)
> 1873                    return 0;
> 1874
> 
> Fixes: 1208f9e1d758c9 ("USB: hub: Fix the broken detection of USB3 device in SMSC hub")
> Cc: Hardik Gajjar <hgajjar@...adit-jv.com>
> Cc: Alan Stern <stern@...land.harvard.edu>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Reported-by: scan-admin@...erity.com
> Signed-off-by: Eugeniu Rosca <erosca@...adit-jv.com>
> ---
>  drivers/usb/core/hub.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 1d212f82c69b..ff04ca28970d 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -1865,8 +1865,12 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
>  		hub->quirk_check_port_auto_suspend = 1;
>  
>  	if (id->driver_info & HUB_QUIRK_DISABLE_AUTOSUSPEND) {
> -		hub->quirk_disable_autosuspend = 1;
> -		usb_autopm_get_interface(intf);
> +		int r = usb_autopm_get_interface(intf);
> +
> +		if (!r)
> +			hub->quirk_disable_autosuspend = 1;
> +		else
> +			dev_dbg(&intf->dev, "disable autosuspend err=%d\n", r);
>  	}
>  
>  	if (hub_configure(hub, &desc->endpoint[0].desc) >= 0)

This change is not necessary, because the resume operation cannot fail
at this point (interfaces are always powered-up during probe).  A
better solution would be to call usb_autpm_get_interface_no_resume()
instead.

On the other hand, the other places that call
usb_autopm_get_interface() without checking should be audited.  Some of
them almost certainly need to be fixed.

Alan Stern

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ