linux-stable/drivers/usb
M. Vefa Bicakci 3fce39601a usbcore/driver: Accommodate usbip
Commit 88b7381a93 ("USB: Select better matching USB drivers when
available") inadvertently broke usbip functionality. The commit in
question allows USB device drivers to be explicitly matched with
USB devices via the use of driver-provided identifier tables and
match functions, which is useful for a specialised device driver
to be chosen for a device that can also be handled by another,
more generic, device driver.

Prior, the USB device section of usb_device_match() had an
unconditional "return 1" statement, which allowed user-space to bind
USB devices to the usbip_host device driver, if desired. However,
the aforementioned commit changed the default/fallback return
value to zero. This breaks device drivers such as usbip_host, so
this commit restores the legacy behaviour, but only if a device
driver does not have an id_table and a match() function.

In addition, if usb_device_match is called for a device driver
and device pair where the device does not match the id_table of the
device driver in question, then the device driver will be disqualified
for the device. This allows avoiding the default case of "return 1",
which prevents undesirable probe() calls to a driver even though
its id_table did not match the device.

Finally, this commit changes the specialised-driver-to-generic-driver
transition code so that when a device driver returns -ENODEV, a more
generic device driver is only considered if the current device driver
does not have an id_table and a match() function. This ensures that
"generic" drivers such as usbip_host will not be considered specialised
device drivers and will not cause the device to be locked in to the
generic device driver, when a more specialised device driver could be
tried.

All of these changes restore usbip functionality without regressions,
ensure that the specialised/generic device driver selection logic works
as expected with the usb and apple-mfi-fastcharge drivers, and do not
negatively affect the use of devices provided by dummy_hcd.

Fixes: 88b7381a93 ("USB: Select better matching USB drivers when available")
Cc: <stable@vger.kernel.org> # 5.8
Cc: Bastien Nocera <hadess@hadess.net>
Cc: Valentina Manea <valentina.manea.m@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: <syzkaller@googlegroups.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>
Link: https://lore.kernel.org/r/20200922110703.720960-5-m.v.b@runbox.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-25 16:53:02 +02:00
..
atm usb: Use fallthrough pseudo-keyword 2020-07-10 08:55:17 +02:00
c67x00 treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
cdns3 usb: cdns3: convert to devm_platform_ioremap_resource_byname 2020-07-29 16:49:37 +02:00
chipidea ENDIAN issue fix and one query controller role API is introduced. 2020-07-29 13:57:09 +02:00
class usblp: fix race between disconnect() and read() 2020-09-17 18:45:30 +02:00
common usb: common: usb-conn-gpio: Register charger 2020-07-30 08:45:24 +02:00
core usbcore/driver: Accommodate usbip 2020-09-25 16:53:02 +02:00
dwc2 Revert "usb: dwc2: override PHY input signals with usb role switch support" 2020-07-27 15:34:15 +02:00
dwc3 Revert "usb: dwc3: meson-g12a: fix shared reset control use" 2020-09-04 16:41:22 +02:00
early usb: early: xhci-dbc: File headers are not good candidates for kerneldoc 2020-07-09 17:19:59 +02:00
gadget USB: gadget: f_ncm: Fix NDP16 datagram validation 2020-09-22 18:51:52 +02:00
host ehci-hcd: Move include to keep CRC stable 2020-09-17 08:39:50 +02:00
image usb: Use fallthrough pseudo-keyword 2020-07-10 08:55:17 +02:00
isp1760 usb: Use fallthrough pseudo-keyword 2020-07-10 08:55:17 +02:00
misc USB: lvtest: return proper error code in probe 2020-08-18 11:55:23 +02:00
mon
mtu3 usb: mtu3: simplify mtu3_req_complete() 2020-07-29 16:53:59 +02:00
musb treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
phy USB: PHY: JZ4770: Fix static checker warning. 2020-08-25 16:02:34 +02:00
renesas_usbhs usb: Use fallthrough pseudo-keyword 2020-07-10 08:55:17 +02:00
roles usb: roles: Switch on role-switch uevent reporting 2020-05-13 14:20:49 +02:00
serial USB: serial: option: support dynamic Quectel USB compositions 2020-08-31 08:37:17 +02:00
storage USB: UAS: fix disconnect by unplugging a hub 2020-09-16 12:35:14 +02:00
typec usb: typec: intel_pmc_mux: Handle SCU IPC error conditions 2020-09-16 13:09:31 +02:00
usbip Revert "usbip: Implement a match function to fix usbip" 2020-09-25 16:50:11 +02:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile
usb-skeleton.c