kernel-ark/drivers/usb/gadget
Yauheni Kaliuta 91960c2ef0 usb: gadget: file_storage: fix race on unloading
There is a race, reproduced rarely if you unload the module
when host finishes mass storage device initialization (reading
partition table and so on): fsg_unbind() code first closes
lun files then waits for worker thread to finish its work, as
the result the thread may operate on already closed device
with an oops and backtrace:

[  484.937225] [<b00e403c>] (touch_atime+0x4/0x140) from [<b00a1498>] (generic_file_aio_read+0x678/0x6f0)
[  484.946563] [<b00a1498>] (generic_file_aio_read+0x678/0x6f0) from [<b00d08c4>] (do_sync_read+0xb0/0xf4)
[  484.955963] [<b00d08c4>] (do_sync_read+0xb0/0xf4) from [<b00d1478>] (vfs_read+0xac/0x144)
[  484.964172] [<b00d1478>] (vfs_read+0xac/0x144) from [<af24c6a8>] (fsg_setup+0x7f4/0x900 [g_file_storage])
[  484.973785] [<af24c6a8>] (fsg_setup+0x7f4/0x900 [g_file_storage]) from [<af24da14>] (fsg_main_thread+0x85c/0x175c [g_file_storage])
[  484.985626] [<af24da14>] (fsg_main_thread+0x85c/0x175c [g_file_storage]) from [<b0077c48>] (kthread+0x7c/0x84)
[  484.995666] [<b0077c48>] (kthread+0x7c/0x84) from [<b002f950>] (kernel_thread_exit+0x0/0x8)
[  485.004028] Code: eaffffd0 e28dd008 e8bd8df0 e92d40f7 (e591400c)

Change the order in unbind: wait for the thread first, then close
the files.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@nokia.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-18 13:49:17 -07:00
..
acm_ms.c usb: gadget: add new usb gadget for ACM and mass storage 2011-10-13 20:46:27 +03:00
amd5536udc.c usb: Provide usb_speed_string() function 2011-09-18 01:29:04 -07:00
amd5536udc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
at91_udc.c usb: gadget: at91_udc: change french comments to english 2011-10-13 20:39:54 +03:00
at91_udc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
atmel_usba_udc.c usb: Provide usb_speed_string() function 2011-09-18 01:29:04 -07:00
atmel_usba_udc.h
audio.c usb: gadget: add max_speed to usb_composite_driver 2011-07-01 14:27:05 -07:00
cdc2.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
ci13xxx_msm.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
ci13xxx_pci.c
ci13xxx_udc.c USB: use usb_endpoint_maxp() instead of le16_to_cpu() 2011-08-23 09:47:40 -07:00
ci13xxx_udc.h
composite.c usb: gadget: fix typo for default U1/U2 exit latencies 2011-10-13 20:39:59 +03:00
config.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
dbgp.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
dummy_hcd.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
epautoconf.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
ether.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_acm.c usb: gadget: use config_ep_by_speed() instead of ep_choose() 2011-06-28 11:14:37 -07:00
f_audio.c usb: gadget: audio: queue wLength-sized requests 2011-09-09 13:06:06 +03:00
f_ecm.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_eem.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_fs.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_hid.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_loopback.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_mass_storage.c usb: gadget: storage: add superspeed support 2011-10-13 20:39:59 +03:00
f_midi.c USB: gadget: f_midi: allow a dynamic number of input and output ports 2011-10-13 20:39:52 +03:00
f_ncm.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_obex.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_phonet.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_rndis.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_serial.c usb: gadget: use config_ep_by_speed() instead of ep_choose() 2011-06-28 11:14:37 -07:00
f_sourcesink.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_subset.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_uvc.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
f_uvc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
file_storage.c usb: gadget: file_storage: fix race on unloading 2011-10-18 13:49:17 -07:00
fsl_mxc_udc.c
fsl_qe_udc.c USB: use usb_endpoint_maxp() instead of le16_to_cpu() 2011-08-23 09:47:40 -07:00
fsl_qe_udc.h
fsl_udc_core.c usb: Provide usb_speed_string() function 2011-09-18 01:29:04 -07:00
fsl_usb2_udc.h
fusb300_udc.c USB: irq: Remove IRQF_DISABLED 2011-09-18 01:39:36 -07:00
fusb300_udc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
g_ffs.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
g_zero.h
gadget_chips.h usb: gadget: introduce gadget_is_dwc3() 2011-08-22 16:00:46 -07:00
gmidi.c USB: gadget: f_midi: allow a dynamic number of input and output ports 2011-10-13 20:39:52 +03:00
goku_udc.c usb: gadget: convert all users to the new udc infrastructure 2011-06-28 11:13:35 -07:00
goku_udc.h
hid.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
imx_udc.c USB: irq: Remove IRQF_DISABLED 2011-09-18 01:39:36 -07:00
imx_udc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
inode.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
Kconfig usb: gadget: add new usb gadget for ACM and mass storage 2011-10-13 20:46:27 +03:00
langwell_udc.c usb: gadget: langwell: convert to new style 2011-10-13 20:39:55 +03:00
langwell_udc.h usb: gadget: langwell: convert to new style 2011-10-13 20:39:55 +03:00
m66592-udc.c USB: irq: Remove IRQF_DISABLED 2011-09-18 01:39:36 -07:00
m66592-udc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
Makefile usb: gadget: add new usb gadget for ACM and mass storage 2011-10-13 20:46:27 +03:00
mass_storage.c usb: gadget: storage: add superspeed support 2011-10-13 20:39:59 +03:00
multi.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
mv_udc_core.c usb: gadget: mv_udc: fix compile warning 2011-10-13 20:42:10 +03:00
mv_udc.h usb: gadget: mv_udc: add clock gating support 2011-10-13 20:42:09 +03:00
ncm.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
ndis.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
net2272.c usb: gadget: net2272: convert to new style 2011-10-13 20:39:56 +03:00
net2272.h USB: net2272: driver for PLX NET2272 USB device controller 2011-06-06 16:47:27 -07:00
net2280.c usb: gadget: net2280: convert to new style 2011-10-13 20:39:57 +03:00
net2280.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
nokia.c usb: gadget: add max_speed to usb_composite_driver 2011-07-01 14:27:05 -07:00
omap_udc.c USB: irq: Remove IRQF_DISABLED 2011-09-18 01:39:36 -07:00
omap_udc.h
pch_udc.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
printer.c USB: g_printer: fix bug in unregistration 2011-09-18 01:33:06 -07:00
pxa25x_udc.c USB: irq: Remove IRQF_DISABLED 2011-09-18 01:39:36 -07:00
pxa25x_udc.h usb: gadget: pxa25x: is_vbus_present is gone 2011-10-13 20:39:53 +03:00
pxa27x_udc.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
pxa27x_udc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
r8a66597-udc.c usb: gadget: r8a66597: convert to new style 2011-10-13 20:39:58 +03:00
r8a66597-udc.h usb: gadget: r8a66597-udc: add support for SUDMAC 2011-10-13 20:38:39 +03:00
rndis.c
rndis.h
s3c2410_udc.c USB: irq: Remove IRQF_DISABLED 2011-09-18 01:39:36 -07:00
s3c2410_udc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
s3c-hsotg.c usb: Provide usb_speed_string() function 2011-09-18 01:29:04 -07:00
s3c-hsudc.c s3c-hsudc: implement vbus_draw hook 2011-09-18 01:33:06 -07:00
serial.c usb: gadget: add max_speed to usb_composite_driver 2011-07-01 14:27:05 -07:00
storage_common.c usb: gadget: storage: add superspeed support 2011-10-13 20:39:59 +03:00
u_audio.c
u_audio.h
u_ether.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
u_ether.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
u_phonet.h
u_serial.c USB: gadget: u_serial.c: fixed a brace coding style issue 2011-09-26 15:49:42 -07:00
u_serial.h usb: gadget: add usb_endpoint_descriptor to struct usb_ep 2011-06-28 11:14:36 -07:00
udc-core.c usb: gadget: udc-core: fix bug on soft_connect interface 2011-09-26 15:36:07 -07:00
usbstring.c
uvc_queue.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
uvc_queue.h
uvc_v4l2.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
uvc_video.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
uvc.h usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
webcam.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00
zero.c usb gadget: clean up FSF boilerplate text 2011-09-09 16:00:09 -07:00