]> git.sur5r.net Git - u-boot/commitdiff
net: davinci_emac: fix NULL check after pointer dereference
authorVishwas Srivastava <vishu.kernel@gmail.com>
Tue, 26 Jan 2016 07:16:42 +0000 (12:46 +0530)
committerAnatolij Gustschin <agust@denx.de>
Sat, 6 Feb 2016 15:39:31 +0000 (16:39 +0100)
NULL check is made after the pointer dereference. This patch
fixes this issue.

Signed-off-by: Vishwas Srivastava <vishu.kernel@gmail.com>
CC: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
drivers/net/davinci_emac.c

index 6f2dc8d64882dc72ded605fae3f17215066ca836..b03049840286339384d4358fc46f15af66c78ac0 100644 (file)
@@ -692,8 +692,10 @@ static int davinci_eth_rcv_packet (struct eth_device *dev)
        davinci_invalidate_rx_descs();
 
        rx_curr_desc = emac_rx_active_head;
+       if (!rx_curr_desc)
+               return 0;
        status = rx_curr_desc->pkt_flag_len;
-       if ((rx_curr_desc) && ((status & EMAC_CPPI_OWNERSHIP_BIT) == 0)) {
+       if ((status & EMAC_CPPI_OWNERSHIP_BIT) == 0) {
                if (status & EMAC_CPPI_RX_ERROR_FRAME) {
                        /* Error in packet - discard it and requeue desc */
                        printf ("WARN: emac_rcv_pkt: Error in packet\n");