Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1276649

[PATCH] TTY: n_gsm, fix false positive WARN_ON

From Jiri Slaby <jslaby@suse.cz>
Newsgroups linux.kernel
Subject [PATCH] TTY: n_gsm, fix false positive WARN_ON
Date 2015-11-24 18:00 +0100
Message-ID <qyp6F-2hl-3@gated-at.bofh.it> (permalink)
References <qyjaW-6V9-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Dmitry reported, that the current cleanup code in n_gsm can trigger a
warning:
WARNING: CPU: 2 PID: 24238 at drivers/tty/n_gsm.c:2048 gsm_cleanup_mux+0x166/0x6b0()
...
Call Trace:
...
 [<ffffffff81247ab9>] warn_slowpath_null+0x29/0x30 kernel/panic.c:490
 [<ffffffff828d0456>] gsm_cleanup_mux+0x166/0x6b0 drivers/tty/n_gsm.c:2048
 [<ffffffff828d4d87>] gsmld_open+0x5b7/0x7a0 drivers/tty/n_gsm.c:2386
 [<ffffffff828b9078>] tty_ldisc_open.isra.2+0x78/0xd0 drivers/tty/tty_ldisc.c:447
 [<ffffffff828b973a>] tty_set_ldisc+0x1ca/0xa70 drivers/tty/tty_ldisc.c:567
 [<     inline     >] tiocsetd drivers/tty/tty_io.c:2650
 [<ffffffff828a14ea>] tty_ioctl+0xb2a/0x2140 drivers/tty/tty_io.c:2883
...

But this is a legal path when open fails to find a space in the
gsm_mux array and tries to clean up. So make it a standard test
instead of a warning.

Reported-by: "Dmitry Vyukov" <dvyukov@google.com>
Cc: Alan Cox <alan@linux.intel.com>
Link: http://lkml.kernel.org/r/CACT4Y+bHQbAB68VFi7Romcs-Z9ZW3kQRvcq+BvHH1oa5NcAdLA@mail.gmail.com
Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/n_gsm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index c3fe026d3168..9aff37186246 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2045,7 +2045,9 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm)
 		}
 	}
 	spin_unlock(&gsm_mux_lock);
-	WARN_ON(i == MAX_MUX);
+	/* open failed before registering => nothing to do */
+	if (i == MAX_MUX)
+		return;
 
 	/* In theory disconnecting DLCI 0 is sufficient but for some
 	   modems this is apparently not the case. */
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

WARNING in gsm_cleanup_mux Dmitry Vyukov <dvyukov@google.com> - 2015-11-24 11:40 +0100
  [PATCH] TTY: n_gsm, fix false positive WARN_ON Jiri Slaby <jslaby@suse.cz> - 2015-11-24 18:00 +0100
    Re: [PATCH] TTY: n_gsm, fix false positive WARN_ON xinhui <xinhui@linux.vnet.ibm.com> - 2015-11-25 07:40 +0100
      Re: [PATCH] TTY: n_gsm, fix false positive WARN_ON Jiri Slaby <jslaby@suse.cz> - 2015-11-25 11:00 +0100
        Re: [PATCH] TTY: n_gsm, fix false positive WARN_ON xinhui <xinhui@linux.vnet.ibm.com> - 2015-11-25 11:40 +0100

csiph-web