diff mbox series

[v3,1/3] usb: core: hub: fix unhandled return by employing a void function

Message ID 20200226175036.14946-1-erosca@de.adit-jv.com (mailing list archive)
State Mainlined
Commit 63d6d7ed475c53dc1cabdfedf63de1fd8dcd72ee
Headers show
Series [v3,1/3] usb: core: hub: fix unhandled return by employing a void function | expand

Commit Message

Eugeniu Rosca Feb. 26, 2020, 5:50 p.m. UTC
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

Rather than checking the return value of 'usb_autopm_get_interface()',
switch to the usb_autopm_get_interface_no_resume() API, as per:

On Tue, Feb 25, 2020 at 10:32:32AM -0500, Alan Stern wrote:
 ------ 8< ------
 > This change (i.e. 'ret = usb_autopm_get_interface') 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_autopm_get_interface_no_resume() instead.
 ------ 8< ------

Fixes: 1208f9e1d758c9 ("USB: hub: Fix the broken detection of USB3 device in SMSC hub")
Cc: Hardik Gajjar <hgajjar@de.adit-jv.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable@vger.kernel.org # v4.14+
Reported-by: scan-admin@coverity.com
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
v3:
 - Make the summary line more clear
 - s/autpm/autopm/ in patch description
 - Cc <stable> with v4.14+ since v4.14.x is the earliest stable kernel
   which accepted commit 1208f9e1d758c9 ("USB: hub: Fix the broken
   detection of USB3 device in SMSC hub")

v2:
 - [Alan Stern] Use usb_autopm_get_interface_no_resume() instead of
   usb_autopm_get_interface()
 - Augment commit description to provide background
 - Link: https://lore.kernel.org/lkml/20200225183057.31953-1-erosca@de.adit-jv.com

v1:
 - Link: https://lore.kernel.org/lkml/20200225130846.20236-1-erosca@de.adit-jv.com
---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alan Stern Feb. 26, 2020, 6:14 p.m. UTC | #1
On Wed, 26 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
> 
> Rather than checking the return value of 'usb_autopm_get_interface()',
> switch to the usb_autopm_get_interface_no_resume() API, as per:
> 
> On Tue, Feb 25, 2020 at 10:32:32AM -0500, Alan Stern wrote:
>  ------ 8< ------
>  > This change (i.e. 'ret = usb_autopm_get_interface') 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_autopm_get_interface_no_resume() instead.
>  ------ 8< ------
> 
> Fixes: 1208f9e1d758c9 ("USB: hub: Fix the broken detection of USB3 device in SMSC hub")
> Cc: Hardik Gajjar <hgajjar@de.adit-jv.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: stable@vger.kernel.org # v4.14+
> Reported-by: scan-admin@coverity.com
> Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>

For all three patches:

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Eugeniu Rosca March 3, 2020, 10:40 a.m. UTC | #2
Hi Greg,

On Wed, Feb 26, 2020 at 01:14:24PM -0500, Alan Stern wrote:
> On Wed, 26 Feb 2020, Eugeniu Rosca wrote:
> > 
> > Fixes: 1208f9e1d758c9 ("USB: hub: Fix the broken detection of USB3 device in SMSC hub")
> > Cc: Hardik Gajjar <hgajjar@de.adit-jv.com>
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: stable@vger.kernel.org # v4.14+
> > Reported-by: scan-admin@coverity.com
> > Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> > Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> 
> For all three patches:
> 
> Acked-by: Alan Stern <stern@rowland.harvard.edu>

Friendly reminder to pick up the patches, if no other comments.
Greg Kroah-Hartman March 3, 2020, 10:57 a.m. UTC | #3
On Tue, Mar 03, 2020 at 11:40:05AM +0100, Eugeniu Rosca wrote:
> Hi Greg,
> 
> On Wed, Feb 26, 2020 at 01:14:24PM -0500, Alan Stern wrote:
> > On Wed, 26 Feb 2020, Eugeniu Rosca wrote:
> > > 
> > > Fixes: 1208f9e1d758c9 ("USB: hub: Fix the broken detection of USB3 device in SMSC hub")
> > > Cc: Hardik Gajjar <hgajjar@de.adit-jv.com>
> > > Cc: Alan Stern <stern@rowland.harvard.edu>
> > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > Cc: stable@vger.kernel.org # v4.14+
> > > Reported-by: scan-admin@coverity.com
> > > Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> > > Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> > 
> > For all three patches:
> > 
> > Acked-by: Alan Stern <stern@rowland.harvard.edu>
> 
> Friendly reminder to pick up the patches, if no other comments.

Less than a week, please give me a chance :)

Don't worry, they are in my to-review queue...

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 1d212f82c69b..1105983b5c1c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1866,7 +1866,7 @@  static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
 	if (id->driver_info & HUB_QUIRK_DISABLE_AUTOSUSPEND) {
 		hub->quirk_disable_autosuspend = 1;
-		usb_autopm_get_interface(intf);
+		usb_autopm_get_interface_no_resume(intf);
 	}
 
 	if (hub_configure(hub, &desc->endpoint[0].desc) >= 0)