linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] jsm_tty: Fix a possible null pointer dereference in two functions
@ 2017-11-29 16:40 SF Markus Elfring
  2017-11-29 17:23 ` Joe Perches
  0 siblings, 1 reply; 13+ messages in thread
From: SF Markus Elfring @ 2017-11-29 16:40 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Guilherme G. Piccoli,
	Jiri Slaby, Joe Perches
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 29 Nov 2017 17:30:36 +0100

Move two debug messages so that a null pointer access can not happen
for the variable "ch" in these functions.

This issue was detected by using the Coccinelle software.

Fixes: 669fef464468d3f02d60a5cf725fc097e03c5cb8 ("serial: jsm: Convert jsm_printk to jsm_dbg")

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/tty/serial/jsm/jsm_tty.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 469927d37b41..a34eed7344e5 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -521,11 +521,10 @@ void jsm_input(struct jsm_channel *ch)
 	int s = 0;
 	int i = 0;
 
-	jsm_dbg(READ, &ch->ch_bd->pci_dev, "start\n");
-
 	if (!ch)
 		return;
 
+	jsm_dbg(READ, &ch->ch_bd->pci_dev, "start\n");
 	port = &ch->uart_port.state->port;
 	tp = port->tty;
 
@@ -647,10 +646,10 @@ static void jsm_carrier(struct jsm_channel *ch)
 	int virt_carrier = 0;
 	int phys_carrier = 0;
 
-	jsm_dbg(CARR, &ch->ch_bd->pci_dev, "start\n");
 	if (!ch)
 		return;
 
+	jsm_dbg(CARR, &ch->ch_bd->pci_dev, "start\n");
 	bd = ch->ch_bd;
 
 	if (!bd)
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-12-18 17:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-29 16:40 [PATCH] jsm_tty: Fix a possible null pointer dereference in two functions SF Markus Elfring
2017-11-29 17:23 ` Joe Perches
2017-11-29 17:35   ` Greg Kroah-Hartman
2017-11-29 17:51     ` Joe Perches
2017-11-29 18:05       ` Greg Kroah-Hartman
2017-11-29 18:16         ` Joe Perches
2017-11-29 18:19         ` SF Markus Elfring
2017-11-30  6:41           ` Jiri Slaby
2017-12-06 16:16           ` Guilherme G. Piccoli
2017-12-16  6:27             ` jsm_tty: Deletion of a null pointer check in two functions? SF Markus Elfring
2017-12-18 14:36               ` Guilherme G. Piccoli
2017-12-18 17:14                 ` SF Markus Elfring
2017-11-29 19:16   ` [PATCH] jsm_tty: Fix a possible null pointer dereference in two functions Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).