Commit 1f8b39bc authored by Eugeniu Rosca's avatar Eugeniu Rosca Committed by Greg Kroah-Hartman

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/Pine.LNX.4.44L0.2002251419120.1485-100000@iolanthe.rowland.org

Fixes: 971fcd49 ("usb: add runtime pm support for usb port device")
Cc: stable@vger.kernel.org # v3.9+
Suggested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20200226175036.14946-3-erosca@de.adit-jv.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 60e3f6e4
...@@ -213,7 +213,10 @@ static int usb_port_runtime_resume(struct device *dev) ...@@ -213,7 +213,10 @@ static int usb_port_runtime_resume(struct device *dev)
if (!port_dev->is_superspeed && peer) if (!port_dev->is_superspeed && peer)
pm_runtime_get_sync(&peer->dev); pm_runtime_get_sync(&peer->dev);
usb_autopm_get_interface(intf); retval = usb_autopm_get_interface(intf);
if (retval < 0)
return retval;
retval = usb_hub_set_port_power(hdev, hub, port1, true); retval = usb_hub_set_port_power(hdev, hub, port1, true);
msleep(hub_power_on_good_delay(hub)); msleep(hub_power_on_good_delay(hub));
if (udev && !retval) { if (udev && !retval) {
...@@ -266,7 +269,10 @@ static int usb_port_runtime_suspend(struct device *dev) ...@@ -266,7 +269,10 @@ static int usb_port_runtime_suspend(struct device *dev)
if (usb_port_block_power_off) if (usb_port_block_power_off)
return -EBUSY; return -EBUSY;
usb_autopm_get_interface(intf); retval = usb_autopm_get_interface(intf);
if (retval < 0)
return retval;
retval = usb_hub_set_port_power(hdev, hub, port1, false); retval = usb_hub_set_port_power(hdev, hub, port1, false);
usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION); usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION);
if (!port_dev->is_superspeed) if (!port_dev->is_superspeed)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment