Skip to content

Commit 1f8b39b

Browse files
Eugeniu Roscagregkh
authored andcommitted
usb: core: port: 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_port_runtime_{resume,suspend}() changes into a standalone patch to allow conflict-free porting on top of stable v3.9+. [1] https://lore.kernel.org/lkml/[email protected] Fixes: 971fcd4 ("usb: add runtime pm support for usb port device") Cc: [email protected] # v3.9+ 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 60e3f6e commit 1f8b39b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/usb/core/port.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ static int usb_port_runtime_resume(struct device *dev)
213213
if (!port_dev->is_superspeed && peer)
214214
pm_runtime_get_sync(&peer->dev);
215215

216-
usb_autopm_get_interface(intf);
216+
retval = usb_autopm_get_interface(intf);
217+
if (retval < 0)
218+
return retval;
219+
217220
retval = usb_hub_set_port_power(hdev, hub, port1, true);
218221
msleep(hub_power_on_good_delay(hub));
219222
if (udev && !retval) {
@@ -266,7 +269,10 @@ static int usb_port_runtime_suspend(struct device *dev)
266269
if (usb_port_block_power_off)
267270
return -EBUSY;
268271

269-
usb_autopm_get_interface(intf);
272+
retval = usb_autopm_get_interface(intf);
273+
if (retval < 0)
274+
return retval;
275+
270276
retval = usb_hub_set_port_power(hdev, hub, port1, false);
271277
usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION);
272278
if (!port_dev->is_superspeed)

0 commit comments

Comments
 (0)