f9363aaa75cce3447628d712796f32f4a4cdf7be
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.1 / 0047-usb-cdc-acm-Fix-acm_tty_hangup-vs.-acm_tty_close-rac.patch
1 From 9d3898fe46309ee5688697d1a65975208dc49639 Mon Sep 17 00:00:00 2001
2 From: Thilo-Alexander Ginkel <thilo@ginkel.com>
3 Date: Sat, 17 Dec 2011 10:55:10 +0100
4 Subject: [PATCH 47/49] usb: cdc-acm: Fix acm_tty_hangup() vs. acm_tty_close()
5 race
7 [Not upstream as it was fixed differently for 3.3 with a much more
8 "intrusive" rework of the driver - gregkh]
10 There is a race condition involving acm_tty_hangup() and acm_tty_close()
11 where hangup() would attempt to access tty->driver_data without proper
12 locking and NULL checking after close() has potentially already set it
13 to NULL. One possibility to (sporadically) trigger this behavior is to
14 perform a suspend/resume cycle with a running WWAN data connection.
16 This patch addresses the issue by introducing a NULL check for
17 tty->driver_data in acm_tty_hangup() protected by open_mutex and exiting
18 gracefully when hangup() is invoked on a device that has already been
19 closed.
21 Signed-off-by: Thilo-Alexander Ginkel <thilo@ginkel.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
23 ---
24 drivers/usb/class/cdc-acm.c | 12 ++++++++++--
25 1 files changed, 10 insertions(+), 2 deletions(-)
27 diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
28 index ea5e487..e61d9c4 100644
29 --- a/drivers/usb/class/cdc-acm.c
30 +++ b/drivers/usb/class/cdc-acm.c
31 @@ -554,10 +554,18 @@ static void acm_port_down(struct acm *acm)
33 static void acm_tty_hangup(struct tty_struct *tty)
34 {
35 - struct acm *acm = tty->driver_data;
36 - tty_port_hangup(&acm->port);
37 + struct acm *acm;
38 +
39 mutex_lock(&open_mutex);
40 + acm = tty->driver_data;
41 +
42 + if (!acm)
43 + goto out;
44 +
45 + tty_port_hangup(&acm->port);
46 acm_port_down(acm);
47 +
48 +out:
49 mutex_unlock(&open_mutex);
50 }
52 --
53 1.7.7.4