TTY: serial: move the dereference below the NULL test
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Fri, 7 Sep 2012 06:53:49 +0000 (14:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 10 Sep 2012 23:33:02 +0000 (16:33 -0700)
The dereference should be moved below the NULL test.

spatch with a semantic match is used to found this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/ioc3_serial.c
drivers/tty/serial/ioc4_serial.c

index 758ff310f7f8e044e97ac1e310f18302635f0a5f..5ac52898a0bb68a3ce07ec5d1bfdc61382af318d 100644 (file)
@@ -1120,13 +1120,14 @@ static inline int do_read(struct uart_port *the_port, char *buf, int len)
        struct ioc3_port *port = get_ioc3_port(the_port);
        struct ring *inring;
        struct ring_entry *entry;
-       struct port_hooks *hooks = port->ip_hooks;
+       struct port_hooks *hooks;
        int byte_num;
        char *sc;
        int loop_counter;
 
        BUG_ON(!(len >= 0));
        BUG_ON(!port);
+       hooks = port->ip_hooks;
 
        /* There is a nasty timing issue in the IOC3. When the rx_timer
         * expires or the rx_high condition arises, we take an interrupt.
index cc5aca78ad9b6344001ec97155a829ddba7a855d..3e7da10cebba3525c43f5f63e383e4bca61deeee 100644 (file)
@@ -2069,13 +2069,14 @@ static inline int do_read(struct uart_port *the_port, unsigned char *buf,
        struct ioc4_port *port = get_ioc4_port(the_port, 0);
        struct ring *inring;
        struct ring_entry *entry;
-       struct hooks *hooks = port->ip_hooks;
+       struct hooks *hooks;
        int byte_num;
        char *sc;
        int loop_counter;
 
        BUG_ON(!(len >= 0));
        BUG_ON(!port);
+       hooks = port->ip_hooks;
 
        /* There is a nasty timing issue in the IOC4. When the rx_timer
         * expires or the rx_high condition arises, we take an interrupt.