usb: core: stop USB enumeration if too many retries
authorRay Chi <raychi@google.com>
Mon, 7 Nov 2022 07:27:54 +0000 (15:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Nov 2022 15:50:21 +0000 (16:50 +0100)
commit430d57f53eb1cdbf9ba9bbd397317912b3cd2de5
treed099fea6ebe65a15b293b203ee8461c4ab6bbeec
parent04914233561377fc0369b984c9d19ec1b6ce2845
usb: core: stop USB enumeration if too many retries

When a broken USB accessory connects to a USB host, usbcore might
keep doing enumeration retries. If the host has a watchdog mechanism,
the kernel panic will happen on the host.

This patch provides an attribute early_stop to limit the numbers of retries
for each port of a hub. If a port was marked with early_stop attribute,
unsuccessful connection attempts will fail quickly. In addition, if an
early_stop port has failed to initialize, it will ignore all future
connection events until early_stop attribute is clear.

Signed-off-by: Ray Chi <raychi@google.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20221107072754.3336357-1-raychi@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/ABI/testing/sysfs-bus-usb
drivers/usb/core/hub.c
drivers/usb/core/hub.h
drivers/usb/core/port.c