usb: cdc-acm: Fix acm_tty_hangup() vs. acm_tty_close() race
authorThilo-Alexander Ginkel <thilo@ginkel.com>
Sat, 17 Dec 2011 09:55:10 +0000 (10:55 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 12 Jan 2012 19:29:46 +0000 (11:29 -0800)
commitf9fd8d6232137e255fc9409a81cf282817472b6f
treed1bebc5ff8a4372ae6d44dd5b8b62005f6e33a07
parentf60d8cd0b0e0def00c9ac54bb4becae034138484
usb: cdc-acm: Fix acm_tty_hangup() vs. acm_tty_close() race

[Not upstream as it was fixed differently for 3.3 with a much more
"intrusive" rework of the driver - gregkh]

There is a race condition involving acm_tty_hangup() and acm_tty_close()
where hangup() would attempt to access tty->driver_data without proper
locking and NULL checking after close() has potentially already set it
to NULL.  One possibility to (sporadically) trigger this behavior is to
perform a suspend/resume cycle with a running WWAN data connection.

This patch addresses the issue by introducing a NULL check for
tty->driver_data in acm_tty_hangup() protected by open_mutex and exiting
gracefully when hangup() is invoked on a device that has already been
closed.

Signed-off-by: Thilo-Alexander Ginkel <thilo@ginkel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/class/cdc-acm.c