]> bbs.cooldavid.org Git - net-next-2.6.git/commit
USB: gadget: f_mass_storage: stale common->fsg value bug fix
authorMichal Nazarewicz <m.nazarewicz@samsung.com>
Fri, 25 Jun 2010 14:29:28 +0000 (16:29 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 30 Jun 2010 15:16:07 +0000 (08:16 -0700)
commitb894f60a232d552fc18b018271c2893f0b0c1c15
treebfe023045f34f7af982bbde73a90f7b562976a2a
parente5fd39d9b80aaa0b8a16dd570fa55009905d6af4
USB: gadget: f_mass_storage: stale common->fsg value bug fix

On fsg_unbind the common->fsg pointer was not NULLed if the
unbound fsg_dev instance was the current one.  As an effect,
the incorrect pointer was preserved in all further operations
which caused do_set_interface to reference an invalid region.

This commit fixes this by raising an exception in fsg_bind
which will change the common->fsg pointer.  This also requires
an wait queue so that the thread in fsg_bind can wait till the
worker thread handles the exception.

This commit removes also a config and new_config fields of
fsg_common as they are no longer needed since fsg can be
used to determine whether function is active or not.

Moreover, this commit removes possible race condition where
the fsg field was modified in both the worker thread and
form various other contexts.  This is fixed by replacing
prev_fsg with new_fsg.  At this point, fsg is assigned only
in worker thread.

Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/f_mass_storage.c