staging: r8188eu: Fix smatch warnings in core/rtw_recv.c
authorLarry Finger <Larry.Finger@lwfinger.net>
Wed, 4 Sep 2013 20:56:10 +0000 (15:56 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Sep 2013 14:47:45 +0000 (07:47 -0700)
Smatch reports the following:
drivers/staging/rtl8188eu/core/rtw_recv.c:211 rtw_free_recvframe() warn: variable dereferenced before check 'precvframe' (see line 207)
drivers/staging/rtl8188eu/core/rtw_recv.c:1803 amsdu_to_msdu() warn: variable dereferenced before check 'sub_skb' (see line 1784)

The code was rearranged to eliminate the dereference before the check.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_recv.c

index 55851997f21c80fe094cbff706111fdd13d31b4c..ba8e53463d10140f1d2db27e9c44a20adc3c36e3 100644 (file)
@@ -204,12 +204,14 @@ void rtw_init_recvframe(union recv_frame *precvframe, struct recv_priv *precvpri
 int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_queue)
 {
        unsigned long irqL;
-       struct adapter *padapter = precvframe->u.hdr.adapter;
-       struct recv_priv *precvpriv = &padapter->recvpriv;
+       struct adapter *padapter;
+       struct recv_priv *precvpriv;
 
 _func_enter_;
        if (!precvframe)
                return _FAIL;
+       padapter = precvframe->u.hdr.adapter;
+       precvpriv = &padapter->recvpriv;
        if (precvframe->u.hdr.pkt) {
                dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */
                precvframe->u.hdr.pkt = NULL;
@@ -1799,16 +1801,14 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)
                        memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN);
                }
 
-               /* Indicat the packets to upper layer */
-               if (sub_skb) {
-                       /*  Insert NAT2.5 RX here! */
-                       sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev);
-                       sub_skb->dev = padapter->pnetdev;
+               /* Indicate the packets to upper layer */
+               /*  Insert NAT2.5 RX here! */
+               sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev);
+               sub_skb->dev = padapter->pnetdev;
 
-                       sub_skb->ip_summed = CHECKSUM_NONE;
+               sub_skb->ip_summed = CHECKSUM_NONE;
 
-                       netif_rx(sub_skb);
-               }
+               netif_rx(sub_skb);
        }
 
 exit: