linux/drivers/usb/gadget/legacy
Michal Nazarewicz f78bbcae86 usb: f_mass_storage: test whether thread is running before starting another
When binding the function to usb_configuration, check whether the thread
is running before starting another one.  Without that, when function
instance is added to multiple configurations, fsg_bing starts multiple
threads with all but the latest one being forgotten by the driver.  This
leads to obvious thread leaks, possible lockups when trying to halt the
machine and possible more issues.

This fixes issues with legacy/multi¹ gadget as well as configfs gadgets
when mass_storage function is added to multiple configurations.

This change also simplifies API since the legacy gadgets no longer need
to worry about starting the thread by themselves (which was where bug
in legacy/multi was in the first place).

N.B., this patch doesn’t address adding single mass_storage function
instance to a single configuration twice.  Thankfully, there’s no
legitimate reason for such setup plus, if I’m not mistaken, configfs
gadget doesn’t even allow it to be expressed.

¹ I have no example failure though.  Conclusion that legacy/multi has
  a bug is based purely on me reading the code.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Tested-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2016-04-19 11:11:56 +03:00
..
Kconfig Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2016-03-17 21:38:27 -07:00
Makefile usb: gadget: webcam: convert webcam to new interface of f_uvc 2014-09-09 09:49:31 -05:00
acm_ms.c usb: f_mass_storage: test whether thread is running before starting another 2016-04-19 11:11:56 +03:00
audio.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
cdc2.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
dbgp.c usb: gadget: legacy: dbgp: eliminate abuse of ep->driver data 2015-09-27 10:54:31 -05:00
ether.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
g_ffs.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
gmidi.c usb: gadget: f_midi: pre-allocate IN requests 2015-12-16 10:07:29 -06:00
hid.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
inode.c mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros 2016-04-04 10:41:08 -07:00
mass_storage.c usb: f_mass_storage: test whether thread is running before starting another 2016-04-19 11:11:56 +03:00
multi.c usb: f_mass_storage: test whether thread is running before starting another 2016-04-19 11:11:56 +03:00
ncm.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
nokia.c usb: f_mass_storage: test whether thread is running before starting another 2016-04-19 11:11:56 +03:00
printer.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
serial.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
tcm_usb_gadget.c Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2016-01-20 17:20:53 -08:00
webcam.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00
zero.c usb: gadget: composite: remove redundant bcdUSB setting in legacy 2015-12-15 09:12:41 -06:00