Skip to content

Commit

Permalink
s390/3270: fix use after free of tty3270_screen structure
Browse files Browse the repository at this point in the history
The deactivation and freeing of the tty view of the 3270 device
can race with a tty3270_update invocation via the update timer.
To fix this move the del_timer_sync call for the update timer from
tty3270_free_view to tty3270_free prior to the tty3270_free_screen
call.

Signed-off-by: Martin Schwidefsky <[email protected]>
  • Loading branch information
Martin Schwidefsky committed Dec 16, 2013
1 parent c63bade commit 03439e7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/s390/char/tty3270.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ static void tty3270_resize_work(struct work_struct *work);
*/
static void tty3270_set_timer(struct tty3270 *tp, int expires)
{
if (expires == 0)
del_timer(&tp->timer);
else
mod_timer(&tp->timer, jiffies + expires);
mod_timer(&tp->timer, jiffies + expires);
}

/*
Expand Down Expand Up @@ -744,7 +741,6 @@ tty3270_free_view(struct tty3270 *tp)
{
int pages;

del_timer_sync(&tp->timer);
kbd_free(tp->kbd);
raw3270_request_free(tp->kreset);
raw3270_request_free(tp->read);
Expand Down Expand Up @@ -877,6 +873,7 @@ tty3270_free(struct raw3270_view *view)
{
struct tty3270 *tp = container_of(view, struct tty3270, view);

del_timer_sync(&tp->timer);
tty3270_free_screen(tp->screen, tp->view.rows);
tty3270_free_view(tp);
}
Expand Down

0 comments on commit 03439e7

Please sign in to comment.