From: Vishwas Srivastava Date: Tue, 26 Jan 2016 07:16:42 +0000 (+0530) Subject: net: davinci_emac: fix NULL check after pointer dereference X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=2300184f702656b72394e458bf15f7aaba8af892;p=project%2Fbcm63xx%2Fu-boot.git net: davinci_emac: fix NULL check after pointer dereference NULL check is made after the pointer dereference. This patch fixes this issue. Signed-off-by: Vishwas Srivastava CC: Joe Hershberger Reviewed-by: Tom Rini Acked-by: Joe Hershberger Signed-off-by: Anatolij Gustschin --- diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index 6f2dc8d648..b030498402 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -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");