浏览代码

tty: serial: jsm: Remove unnecessary NULL checks

After inspection made by Markus using Coccinelle software, he
observed that we could possibly be triggering a NULL pointer
dereference in 2 functions [0].

After discussion in mailing list, it was observed in fact
we have two unnecessary checks for NULL pointer, and they
were leading to Coccinelle warn. So, instead of reworking
the code as proposed by him, we hereby remove the
unnecessary checks, and also some unneeded extra lines in
the code.

These two unnecessary NULL checks were tracked in the call
chain as never NULL, so they can be safely removed.
No functional changes are intended.

[0] https://lkml.org/lkml/2017/11/29/705

Suggested-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Guilherme G. Piccoli 7 年之前
父节点
当前提交
8ca31ba8bb
共有 2 个文件被更改,包括 0 次插入9 次删除
  1. 0 3
      drivers/tty/serial/jsm/jsm_neo.c
  2. 0 6
      drivers/tty/serial/jsm/jsm_tty.c

+ 0 - 3
drivers/tty/serial/jsm/jsm_neo.c

@@ -282,9 +282,6 @@ static void neo_copy_data_from_uart_to_queue(struct jsm_channel *ch)
 	u16 head;
 	u16 head;
 	u16 tail;
 	u16 tail;
 
 
-	if (!ch)
-		return;
-
 	/* cache head and tail of queue */
 	/* cache head and tail of queue */
 	head = ch->ch_r_head & RQUEUEMASK;
 	head = ch->ch_r_head & RQUEUEMASK;
 	tail = ch->ch_r_tail & RQUEUEMASK;
 	tail = ch->ch_r_tail & RQUEUEMASK;

+ 0 - 6
drivers/tty/serial/jsm/jsm_tty.c

@@ -523,9 +523,6 @@ void jsm_input(struct jsm_channel *ch)
 
 
 	jsm_dbg(READ, &ch->ch_bd->pci_dev, "start\n");
 	jsm_dbg(READ, &ch->ch_bd->pci_dev, "start\n");
 
 
-	if (!ch)
-		return;
-
 	port = &ch->uart_port.state->port;
 	port = &ch->uart_port.state->port;
 	tp = port->tty;
 	tp = port->tty;
 
 
@@ -648,11 +645,8 @@ static void jsm_carrier(struct jsm_channel *ch)
 	int phys_carrier = 0;
 	int phys_carrier = 0;
 
 
 	jsm_dbg(CARR, &ch->ch_bd->pci_dev, "start\n");
 	jsm_dbg(CARR, &ch->ch_bd->pci_dev, "start\n");
-	if (!ch)
-		return;
 
 
 	bd = ch->ch_bd;
 	bd = ch->ch_bd;
-
 	if (!bd)
 	if (!bd)
 		return;
 		return;