]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.6.1/tty-n_gsm-fix-false-positive-warn_on.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.6.1 / tty-n_gsm-fix-false-positive-warn_on.patch
1 From d175feca89a1c162f60f4e3560ca7bc9437c65eb Mon Sep 17 00:00:00 2001
2 From: Jiri Slaby <jslaby@suse.cz>
3 Date: Tue, 22 Mar 2016 18:09:51 +0100
4 Subject: TTY: n_gsm, fix false positive WARN_ON
5
6 From: Jiri Slaby <jslaby@suse.cz>
7
8 commit d175feca89a1c162f60f4e3560ca7bc9437c65eb upstream.
9
10 Dmitry reported, that the current cleanup code in n_gsm can trigger a
11 warning:
12 WARNING: CPU: 2 PID: 24238 at drivers/tty/n_gsm.c:2048 gsm_cleanup_mux+0x166/0x6b0()
13 ...
14 Call Trace:
15 ...
16 [<ffffffff81247ab9>] warn_slowpath_null+0x29/0x30 kernel/panic.c:490
17 [<ffffffff828d0456>] gsm_cleanup_mux+0x166/0x6b0 drivers/tty/n_gsm.c:2048
18 [<ffffffff828d4d87>] gsmld_open+0x5b7/0x7a0 drivers/tty/n_gsm.c:2386
19 [<ffffffff828b9078>] tty_ldisc_open.isra.2+0x78/0xd0 drivers/tty/tty_ldisc.c:447
20 [<ffffffff828b973a>] tty_set_ldisc+0x1ca/0xa70 drivers/tty/tty_ldisc.c:567
21 [< inline >] tiocsetd drivers/tty/tty_io.c:2650
22 [<ffffffff828a14ea>] tty_ioctl+0xb2a/0x2140 drivers/tty/tty_io.c:2883
23 ...
24
25 But this is a legal path when open fails to find a space in the
26 gsm_mux array and tries to clean up. So make it a standard test
27 instead of a warning.
28
29 Reported-by: "Dmitry Vyukov" <dvyukov@google.com>
30 Cc: Alan Cox <alan@linux.intel.com>
31 Link: http://lkml.kernel.org/r/CACT4Y+bHQbAB68VFi7Romcs-Z9ZW3kQRvcq+BvHH1oa5NcAdLA@mail.gmail.com
32 Fixes: 5a640967 ("tty/n_gsm.c: fix a memory leak in gsmld_open()")
33 Signed-off-by: Jiri Slaby <jslaby@suse.cz>
34 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35
36 ---
37 drivers/tty/n_gsm.c | 4 +++-
38 1 file changed, 3 insertions(+), 1 deletion(-)
39
40 --- a/drivers/tty/n_gsm.c
41 +++ b/drivers/tty/n_gsm.c
42 @@ -2045,7 +2045,9 @@ static void gsm_cleanup_mux(struct gsm_m
43 }
44 }
45 spin_unlock(&gsm_mux_lock);
46 - WARN_ON(i == MAX_MUX);
47 + /* open failed before registering => nothing to do */
48 + if (i == MAX_MUX)
49 + return;
50
51 /* In theory disconnecting DLCI 0 is sufficient but for some
52 modems this is apparently not the case. */