]> git.baikalelectronics.ru Git - kernel.git/commit
usb: core: Unregister device on component_add() failure
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Wed, 9 Feb 2022 16:45:00 +0000 (17:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Feb 2022 09:57:21 +0000 (10:57 +0100)
commit395f1395b4008777fb49cc879a391a1b885d26cc
treea0e1b6a1864efb662fcb41097c2a9b4104eb1fe2
parent49d60052a7fe1742b1dcf8b60d62efc18df271b3
usb: core: Unregister device on component_add() failure

Commit 057d19a84b2e ("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().

Fixes: 057d19a84b2e ("usb: Link the ports to the connectors they are attached to")
Reported-and-tested-by: syzbot+60df062e1c41940cae0f@syzkaller.appspotmail.com
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Link: https://lore.kernel.org/r/20220209164500.8769-1-fmdefrancesco@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/port.c