Commit f18f9498e90327b9b0e245e191029e6e1996d203
Committed by
Greg Kroah-Hartman
1 parent
eeb89d918c
Exists in
master
and in
7 other branches
tty: Push the lock down further into the ldisc code
Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 2 changed files with 9 additions and 5 deletions Side-by-side Diff
drivers/char/tty_io.c
... | ... | @@ -1347,9 +1347,7 @@ |
1347 | 1347 | * If we fail here just call release_tty to clean up. No need |
1348 | 1348 | * to decrement the use counts, as release_tty doesn't care. |
1349 | 1349 | */ |
1350 | - lock_kernel(); | |
1351 | 1350 | retval = tty_ldisc_setup(tty, tty->link); |
1352 | - unlock_kernel(); | |
1353 | 1351 | if (retval) |
1354 | 1352 | goto release_mem_out; |
1355 | 1353 | return tty; |
drivers/char/tty_ldisc.c
... | ... | @@ -445,8 +445,14 @@ |
445 | 445 | static int tty_ldisc_open(struct tty_struct *tty, struct tty_ldisc *ld) |
446 | 446 | { |
447 | 447 | WARN_ON(test_and_set_bit(TTY_LDISC_OPEN, &tty->flags)); |
448 | - if (ld->ops->open) | |
449 | - return ld->ops->open(tty); | |
448 | + if (ld->ops->open) { | |
449 | + int ret; | |
450 | + /* BKL here locks verus a hangup event */ | |
451 | + lock_kernel(); | |
452 | + ret = ld->ops->open(tty); | |
453 | + unlock_kernel(); | |
454 | + return ret; | |
455 | + } | |
450 | 456 | return 0; |
451 | 457 | } |
452 | 458 | |
... | ... | @@ -566,6 +572,7 @@ |
566 | 572 | return 0; |
567 | 573 | } |
568 | 574 | |
575 | + unlock_kernel(); | |
569 | 576 | /* |
570 | 577 | * Problem: What do we do if this blocks ? |
571 | 578 | * We could deadlock here |
... | ... | @@ -573,7 +580,6 @@ |
573 | 580 | |
574 | 581 | tty_wait_until_sent(tty, 0); |
575 | 582 | |
576 | - unlock_kernel(); | |
577 | 583 | mutex_lock(&tty->ldisc_mutex); |
578 | 584 | |
579 | 585 | /* |