Skip to content

Commit 60e3f6e

Browse files
Eugeniu Roscagregkh
authored andcommitted
usb: core: hub: do error out if usb_autopm_get_interface() fails
Reviewing a fresh portion of coverity defects in USB core (specifically CID 1458999), Alan Stern noted below in [1]: On Tue, Feb 25, 2020 at 02:39:23PM -0500, Alan Stern wrote: > A revised search finds line 997 in drivers/usb/core/hub.c and lines > 216, 269 in drivers/usb/core/port.c. (I didn't try looking in any > other directories.) AFAICT all three of these should check the > return value, although a error message in the kernel log probably > isn't needed. Factor out the usb_remove_device() change into a standalone patch to allow conflict-free integration on top of the earliest stable branches. [1] https://lore.kernel.org/lkml/[email protected] Fixes: 253e057 ("USB: add a "remove hardware" sysfs attribute") Cc: [email protected] # v2.6.33+ Suggested-by: Alan Stern <[email protected]> Signed-off-by: Eugeniu Rosca <[email protected]> Acked-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 63d6d7e commit 60e3f6e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/usb/core/hub.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,13 +988,17 @@ int usb_remove_device(struct usb_device *udev)
988988
{
989989
struct usb_hub *hub;
990990
struct usb_interface *intf;
991+
int ret;
991992

992993
if (!udev->parent) /* Can't remove a root hub */
993994
return -EINVAL;
994995
hub = usb_hub_to_struct_hub(udev->parent);
995996
intf = to_usb_interface(hub->intfdev);
996997

997-
usb_autopm_get_interface(intf);
998+
ret = usb_autopm_get_interface(intf);
999+
if (ret < 0)
1000+
return ret;
1001+
9981002
set_bit(udev->portnum, hub->removed_bits);
9991003
hub_port_logical_disconnect(hub, udev->portnum);
10001004
usb_autopm_put_interface(intf);

0 commit comments

Comments
 (0)