From: Eugeniu Rosca <erosca@de.adit-jv.com>
To: Alan Stern <stern@rowland.harvard.edu>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"Lee, Chiasheng" <chiasheng.lee@intel.com>,
Mathieu Malaterre <malat@debian.org>,
Kai-Heng Feng <kai.heng.feng@canonical.com>,
Eugeniu Rosca <roscaeugeniu@gmail.com>,
Eugeniu Rosca <erosca@de.adit-jv.com>, <stable@vger.kernel.org>
Subject: [PATCH v3 2/3] usb: core: hub: do error out if usb_autopm_get_interface() fails
Date: Wed, 26 Feb 2020 18:50:35 +0100 [thread overview]
Message-ID: <20200226175036.14946-2-erosca@de.adit-jv.com> (raw)
In-Reply-To: <20200226175036.14946-1-erosca@de.adit-jv.com>
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/Pine.LNX.4.44L0.2002251419120.1485-100000@iolanthe.rowland.org
Fixes: 253e05724f9230 ("USB: add a "remove hardware" sysfs attribute")
Cc: stable@vger.kernel.org # v2.6.33+
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
v3:
- Newly submitted
---
drivers/usb/core/hub.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 1105983b5c1c..54cd8ef795ec 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -988,13 +988,17 @@ int usb_remove_device(struct usb_device *udev)
{
struct usb_hub *hub;
struct usb_interface *intf;
+ int ret;
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);
+ ret = usb_autopm_get_interface(intf);
+ if (ret < 0)
+ return ret;
+
set_bit(udev->portnum, hub->removed_bits);
hub_port_logical_disconnect(hub, udev->portnum);
usb_autopm_put_interface(intf);
--
2.25.1
next prev parent reply other threads:[~2020-02-26 17:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 17:50 [PATCH v3 1/3] usb: core: hub: fix unhandled return by employing a void function Eugeniu Rosca
2020-02-26 17:50 ` Eugeniu Rosca [this message]
2020-02-26 17:50 ` [PATCH v3 3/3] usb: core: port: do error out if usb_autopm_get_interface() fails Eugeniu Rosca
2020-02-26 18:14 ` [PATCH v3 1/3] usb: core: hub: fix unhandled return by employing a void function Alan Stern
2020-03-03 10:40 ` Eugeniu Rosca
2020-03-03 10:57 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200226175036.14946-2-erosca@de.adit-jv.com \
--to=erosca@de.adit-jv.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=chiasheng.lee@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=kai.heng.feng@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=malat@debian.org \
--cc=roscaeugeniu@gmail.com \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.