[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220208170048.24718-1-fmdefrancesco@gmail.com>
Date: Tue, 8 Feb 2022 18:00:48 +0100
From: "Fabio M. De Francesco" <fmdefrancesco@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: "Fabio M. De Francesco" <fmdefrancesco@...il.com>,
syzbot+60df062e1c41940cae0f@...kaller.appspotmail.com
Subject: [PATCH] usb: core: Unregister device on component_add() failure
Commit 8c67d06f3fd9 ("usb: Link the ports to the connectors they are
attached to") creates a link to the USB Type-C connector for every new
port that is added when possible. If component_add() fails,
usb_hub_create_port_device() prints a warning but does not unregister
the device and does not return errors to the callers.
Syzbot reported a "WARNING in component_del()".
Fix this issue in usb_hub_create_port_device by calling device_unregister()
and returning the errors from component_add().
Reported-by: syzbot+60df062e1c41940cae0f@...kaller.appspotmail.com
Fixes: 8c67d06f3fd9 ("usb: Link the ports to the connectors they are attached to")
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@...il.com>
---
drivers/usb/core/port.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index c2bbf97a79be..8455b235976a 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -605,8 +605,11 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
find_and_link_peer(hub, port1);
retval = component_add(&port_dev->dev, &connector_ops);
- if (retval)
+ if (retval) {
dev_warn(&port_dev->dev, "failed to add component\n");
+ device_unregister(&port_dev->dev);
+ return retval;
+ }
/*
* Enable runtime pm and hold a refernce that hub_configure()
--
2.34.1
Powered by blists - more mailing lists