WSL2-Linux-Kernel/drivers/usb
Hardik Gajjar 2cc5e191d6 usb: gadget: f_ncm: Always set current gadget in ncm_bind()
[ Upstream commit a04224da1f3424b2c607b12a3bd1f0e302fb8231 ]

Previously, gadget assignment to the net device occurred exclusively
during the initial binding attempt.

Nevertheless, the gadget pointer could change during bind/unbind
cycles due to various conditions, including the unloading/loading
of the UDC device driver or the detachment/reconnection of an
OTG-capable USB hub device.

This patch relocates the gether_set_gadget() function out from
ncm_opts->bound condition check, ensuring that the correct gadget
is assigned during each bind request.

The provided logs demonstrate the consistency of ncm_opts throughout
the power cycle, while the gadget may change.

* OTG hub connected during boot up and assignment of gadget and
  ncm_opts pointer

[    2.366301] usb 2-1.5: New USB device found, idVendor=2996, idProduct=0105
[    2.366304] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    2.366306] usb 2-1.5: Product: H2H Bridge
[    2.366308] usb 2-1.5: Manufacturer: Aptiv
[    2.366309] usb 2-1.5: SerialNumber: 13FEB2021
[    2.427989] usb 2-1.5: New USB device found, VID=2996, PID=0105
[    2.428959] dabridge 2-1.5:1.0: dabridge 2-4 total endpoints=5, 0000000093a8d681
[    2.429710] dabridge 2-1.5:1.0: P(0105) D(22.06.22) F(17.3.16) H(1.1) high-speed
[    2.429714] dabridge 2-1.5:1.0: Hub 2-2 P(0151) V(06.87)
[    2.429956] dabridge 2-1.5:1.0: All downstream ports in host mode

[    2.430093] gadget 000000003c414d59 ------> gadget pointer

* NCM opts and associated gadget pointer during First ncm_bind

[   34.763929] NCM opts 00000000aa304ac9
[   34.763930] NCM gadget 000000003c414d59

* OTG capable hub disconnecte or assume driver unload.

[   97.203114] usb 2-1: USB disconnect, device number 2
[   97.203118] usb 2-1.1: USB disconnect, device number 3
[   97.209217] usb 2-1.5: USB disconnect, device number 4
[   97.230990] dabr_udc deleted

* Reconnect the OTG hub or load driver assaign new gadget pointer.

[  111.534035] usb 2-1.1: New USB device found, idVendor=2996, idProduct=0120, bcdDevice= 6.87
[  111.534038] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  111.534040] usb 2-1.1: Product: Vendor
[  111.534041] usb 2-1.1: Manufacturer: Aptiv
[  111.534042] usb 2-1.1: SerialNumber: Superior
[  111.535175] usb 2-1.1: New USB device found, VID=2996, PID=0120
[  111.610995] usb 2-1.5: new high-speed USB device number 8 using xhci-hcd
[  111.630052] usb 2-1.5: New USB device found, idVendor=2996, idProduct=0105, bcdDevice=21.02
[  111.630055] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  111.630057] usb 2-1.5: Product: H2H Bridge
[  111.630058] usb 2-1.5: Manufacturer: Aptiv
[  111.630059] usb 2-1.5: SerialNumber: 13FEB2021
[  111.687464] usb 2-1.5: New USB device found, VID=2996, PID=0105
[  111.690375] dabridge 2-1.5:1.0: dabridge 2-8 total endpoints=5, 000000000d87c961
[  111.691172] dabridge 2-1.5:1.0: P(0105) D(22.06.22) F(17.3.16) H(1.1) high-speed
[  111.691176] dabridge 2-1.5:1.0: Hub 2-6 P(0151) V(06.87)
[  111.691646] dabridge 2-1.5:1.0: All downstream ports in host mode

[  111.692298] gadget 00000000dc72f7a9 --------> new gadget ptr on connect

* NCM opts and associated gadget pointer during second ncm_bind

[  113.271786] NCM opts 00000000aa304ac9 -----> same opts ptr used during first bind
[  113.271788] NCM gadget 00000000dc72f7a9 ----> however new gaget ptr, that will not set
                                                 in net_device due to ncm_opts->bound = true

Signed-off-by: Hardik Gajjar <hgajjar@de.adit-jv.com>
Link: https://lore.kernel.org/r/20231020153324.82794-1-hgajjar@de.adit-jv.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 16:56:19 +00:00
..
atm
c67x00
cdns3 usb: cdnsp: Fixes issue with dequeuing not queued requests 2023-10-19 23:05:37 +02:00
chipidea usb: chipidea: Simplify Tegra DMA alignment code 2023-11-20 11:08:25 +01:00
class USB: usbtmc: Fix direction for 0-length ioctl control messages 2023-05-24 17:36:52 +01:00
common usb: common: usb-conn-gpio: Prevent bailing out if initial role is none 2023-08-16 18:21:59 +02:00
core usb: hub: Guard against accesses to uninitialized BOS descriptors 2023-10-19 23:05:39 +02:00
dwc2 usb: dwc2: fix possible NULL pointer dereference caused by driver concurrency 2023-11-20 11:08:25 +01:00
dwc3 usb: dwc3: Soft reset phy on probe for host 2023-10-19 23:05:35 +02:00
early usb: early: xhci-dbc: Fix a potential out-of-bound memory access 2023-03-10 09:39:39 +01:00
gadget usb: gadget: f_ncm: Always set current gadget in ncm_bind() 2023-11-28 16:56:19 +00:00
host usb: host: xhci-plat: fix possible kernel oops while resuming 2023-11-20 11:08:26 +01:00
image
isp1760
misc USB: sisusbvga: Add endpoint checks 2023-05-30 13:55:31 +01:00
mon usb: mon: make mmapped memory read only 2022-10-12 09:53:28 +02:00
mtu3 usb: mtu3: fix kernel panic at qmu transfer done irq handler 2023-05-11 23:00:33 +09:00
musb usb: musb: Modify the "HWVers" register address 2023-10-19 23:05:35 +02:00
phy usb: phy: mxs: fix getting wrong state with mxs_phy_is_otg_host() 2023-09-19 12:22:44 +02:00
renesas_usbhs usb: renesas: Fix refcount leak bug 2022-08-25 11:40:33 +02:00
roles Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection" 2023-07-23 13:47:25 +02:00
serial USB: serial: option: add Fibocom to DELL custom modem FM101R-GL 2023-10-25 11:59:03 +02:00
storage usb: storage: set 1.50 as the lower bcdDevice for older "Super Top" compatibility 2023-11-08 17:26:49 +01:00
typec usb: typec: tcpm: Fix NULL pointer dereference in tcpm_pd_svdm() 2023-11-08 17:26:50 +01:00
usbip USB: usbip: fix stub_dev hub disconnect 2023-11-20 11:08:26 +01:00
Kconfig
Makefile
usb-skeleton.c