mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: hub: check return value
@ 2017-04-23 11:22 Pan Bian
  2017-04-24  3:55 ` Viresh Kumar
  0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2017-04-23 11:22 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Alan Stern, Mathias Nyman, Guenter Roeck,
	Viresh Kumar, Wolfram Sang, Geert Uytterhoeven, linux-usb
  Cc: linux-kernel, Pan Bian

From: Pan Bian <bianpan2016@163.com>

Function usb_autopm_get_interface() will return a negative errno on
failure, and function usb_autopm_put_interface() should not be called if
it fails. However, in function usb_remove_device(), the return value of
function usb_autopm_get_interface() is not validated before calling
usb_autopm_put_interface().

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/usb/core/hub.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5286bf6..9627175 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -940,16 +940,18 @@ int usb_remove_device(struct usb_device *udev)
 {
 	struct usb_hub *hub;
 	struct usb_interface *intf;
+	int if_err;
 
 	if (!udev->parent)	/* Can't remove a root hub */
 		return -EINVAL;
 	hub = usb_hub_to_struct_hub(udev->parent);
 	intf = to_usb_interface(hub->intfdev);
 
-	usb_autopm_get_interface(intf);
+	if_err = usb_autopm_get_interface(intf);
 	set_bit(udev->portnum, hub->removed_bits);
 	hub_port_logical_disconnect(hub, udev->portnum);
-	usb_autopm_put_interface(intf);
+	if (!if_err)
+		usb_autopm_put_interface(intf);
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-24  3:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-23 11:22 [PATCH 1/1] usb: hub: check return value Pan Bian
2017-04-24  3:55 ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®