On 29/03/2024 02:34, Ping-Ke Shih wrote: > >> I got another idea: if we have a guarantee that the two USB >> interfaces are probed one at a time, then we can move the global >> things into struct rtl_priv. The first probe call will allocate >> the arrays and initialise the mutexes. The second probe call >> will obtain those from the first struct rtl_priv: >> >> int rtl_usb_probe(struct usb_interface *intf, ...) { >> udev = interface_to_usbdev(intf); >> struct ieee80211_hw *first_hw = usb_get_intfdata(udev->actconfig->interface[0]); >> struct rtl_priv *first_rtlpriv = rtl_priv(first_hw); >> > > Could it have racing when obtaining mutexes from second probe? > Should we need a lock to ensure the sequence? > > When driver is going to down, how can mutexes get free safely? > > It seems like we still need another global lock to ensure that. > I asked linux-usb and they said the two interfaces are probed and disconnected one at a time, so it should be fine without another mutex: https://lore.kernel.org/linux-usb/2024032907-smokeless-imperial-f3f9@gregkh/