Skip to content

Commit 9fff139

Browse files
Wesley Chenggregkh
authored andcommitted
usb: gadget: f_mass_storage: Disable eps during disconnect
When receiving a disconnect event from the UDC, the mass storage function driver currently runs the handle_exception() routine asynchronously. For UDCs that support runtime PM, there is a possibility the UDC is already suspended by the time the do_set_interface() is executed. This can lead to HW register access while the UDC is already suspended. Acked-by: Alan Stern <[email protected]> Signed-off-by: Wesley Cheng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b0d5d2a commit 9fff139

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/usb/gadget/function/f_mass_storage.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,16 @@ static void fsg_disable(struct usb_function *f)
23422342
{
23432343
struct fsg_dev *fsg = fsg_from_func(f);
23442344

2345+
/* Disable the endpoints */
2346+
if (fsg->bulk_in_enabled) {
2347+
usb_ep_disable(fsg->bulk_in);
2348+
fsg->bulk_in_enabled = 0;
2349+
}
2350+
if (fsg->bulk_out_enabled) {
2351+
usb_ep_disable(fsg->bulk_out);
2352+
fsg->bulk_out_enabled = 0;
2353+
}
2354+
23452355
__raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, NULL);
23462356
}
23472357

0 commit comments

Comments
 (0)