1
0
Fork 0
alistair23-linux/drivers/tty
Jiri Slaby e9b736d88a TTY: n_hdlc, fix lockdep false positive
The class of 4 n_hdls buf locks is the same because a single function
n_hdlc_buf_list_init is used to init all the locks. But since
flush_tx_queue takes n_hdlc->tx_buf_list.spinlock and then calls
n_hdlc_buf_put which takes n_hdlc->tx_free_buf_list.spinlock, lockdep
emits a warning:
=============================================
[ INFO: possible recursive locking detected ]
4.3.0-25.g91e30a7-default #1 Not tainted
---------------------------------------------
a.out/1248 is trying to acquire lock:
 (&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fd020>] n_hdlc_buf_put+0x20/0x60 [n_hdlc]

but task is already holding lock:
 (&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fdc07>] n_hdlc_tty_ioctl+0x127/0x1d0 [n_hdlc]

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&(&list->spinlock)->rlock);
  lock(&(&list->spinlock)->rlock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by a.out/1248:
 #0:  (&tty->ldisc_sem){++++++}, at: [<ffffffff814c9eb0>] tty_ldisc_ref_wait+0x20/0x50
 #1:  (&(&list->spinlock)->rlock){......}, at: [<ffffffffa01fdc07>] n_hdlc_tty_ioctl+0x127/0x1d0 [n_hdlc]
...
Call Trace:
...
 [<ffffffff81738fd0>] _raw_spin_lock_irqsave+0x50/0x70
 [<ffffffffa01fd020>] n_hdlc_buf_put+0x20/0x60 [n_hdlc]
 [<ffffffffa01fdc24>] n_hdlc_tty_ioctl+0x144/0x1d0 [n_hdlc]
 [<ffffffff814c25c1>] tty_ioctl+0x3f1/0xe40
...

Fix it by initializing the spin_locks separately. This removes also
reduntand memset of a freshly kzallocated space.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:27:46 -08:00
..
hvc drivers/tty: make hvc/hvc_vio.c explicitly non-modular 2016-02-06 23:26:43 -08:00
ipwireless Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2015-04-14 09:50:27 -07:00
serial tty: serial: 8250: Add generic port init macro 2016-02-06 23:15:53 -08:00
vt tty/vt/keyboard: use memdup_user to simplify code 2016-02-06 23:27:46 -08:00
Kconfig ttyFDC: Implement KGDB IO operations. 2015-03-31 12:04:13 +02:00
Makefile TTY: Add MIPS EJTAG Fast Debug Channel TTY driver 2015-03-31 12:04:12 +02:00
amiserial.c tty: Use termios c_*flag macros 2016-01-28 14:13:44 -08:00
bfin_jtag_comm.c TTY: bfin_jtag_comm: remove incorrect wait_until_sent operation 2015-03-07 03:44:14 +01:00
cyclades.c tty: Use termios c_*flag macros 2016-01-28 14:13:44 -08:00
ehv_bytechan.c drivers/tty: make ehv_bytechan.c explicitly non-modular 2016-02-06 23:26:43 -08:00
goldfish.c staging: goldfish: Fix pointer cast for 32 bits 2015-05-31 11:40:14 +09:00
isicom.c tty: Use termios c_*flag macros 2016-01-28 14:13:44 -08:00
metag_da.c tty/metag_da: Avoid module_init/module_exit in non-modular code 2015-06-16 14:12:31 -04:00
mips_ejtag_fdc.c ttyFDC: Fix build problems due to use of module_{init,exit} 2015-10-17 21:29:21 -07:00
moxa.c tty: Remove unused SERIAL_DO_RESTART define 2015-12-13 19:59:48 -08:00
moxa.h
mxser.c tty: mxser: Remove ASYNC_CLOSING 2016-01-28 14:19:12 -08:00
mxser.h
n_gsm.c tty: Use termios c_*flag macros 2016-01-28 14:13:44 -08:00
n_hdlc.c TTY: n_hdlc, fix lockdep false positive 2016-02-06 23:27:46 -08:00
n_r3964.c tty: r3964: Replace/remove bogus tty lock use 2015-10-17 21:11:29 -07:00
n_tracerouter.c n_tracerouter: stop including <asm-generic/bug> 2015-10-15 00:21:10 +02:00
n_tracesink.c n_tracesink: stop including <asm-generic/bug> 2015-10-15 00:21:11 +02:00
n_tracesink.h
n_tty.c n_tty: Ignore all read data when closing 2016-01-28 14:13:44 -08:00
nozomi.c drivers/tty/nozomi.c: rename CONFIG_MAGIC 2015-05-10 19:19:06 +02:00
pty.c tty: Use termios c_*flag macros 2016-01-28 14:13:44 -08:00
rocket.c tty: Remove ASYNC_CLOSING 2016-01-28 14:19:12 -08:00
rocket.h tty: rocket: fix comment of ROCKET_SPD_HI 2015-05-24 12:49:16 -07:00
rocket_int.h tty: rocket: Remove private close_wait 2016-01-28 14:13:44 -08:00
synclink.c tty: Use termios c_*flag macros 2016-01-28 14:13:44 -08:00
synclink_gt.c tty: Use termios c_*flag macros 2016-01-28 14:13:44 -08:00
synclinkmp.c tty: synclinkmp: do not ignore errors in probe() 2016-02-06 23:27:46 -08:00
sysrq.c sysrq: Fix warning in sysrq generated crash. 2015-12-29 16:29:18 -08:00
tty_audit.c tty: audit: Poison tty_audit_buf while process exits 2016-01-27 16:41:04 -08:00
tty_buffer.c tty: Unify receive_buf() code paths 2016-01-28 14:13:44 -08:00
tty_io.c tty: Fix ioctl(FIOASYNC) on hungup file 2016-01-28 11:58:02 -08:00
tty_ioctl.c tty: Use termios c_*flag macros 2016-01-28 14:13:44 -08:00
tty_ldisc.c tty: Eliminate global symbol tty_ldisc_N_TTY 2016-01-27 15:13:28 -08:00
tty_ldsem.c tty: Deinline __ldsem_down_write_nested, save 128 bytes 2015-12-13 19:59:48 -08:00
tty_mutex.c tty: Remove __lockfunc annotation from tty lock functions 2016-01-27 14:28:20 -08:00
tty_port.c tty: Remove ASYNC_CLOSING 2016-01-28 14:19:12 -08:00