Skip to content

Commit

Permalink
usb: cdc-acm: Fix acm_tty_hangup() vs. acm_tty_close() race
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
Thilo-Alexander Ginkel authored and Greg Kroah-Hartman committed Jan 12, 2012
1 parent 18366c3 commit 68f7609
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/usb/class/cdc-acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,18 @@ static void acm_port_down(struct acm *acm)

static void acm_tty_hangup(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
tty_port_hangup(&acm->port);
struct acm *acm;

mutex_lock(&open_mutex);
acm = tty->driver_data;

if (!acm)
goto out;

tty_port_hangup(&acm->port);
acm_port_down(acm);

out:
mutex_unlock(&open_mutex);
}

Expand Down

0 comments on commit 68f7609

Please sign in to comment.