staging: r8188eu: Fix more Smatch warnings and errors
authorLarry Finger <Larry.Finger@lwfinger.net>
Wed, 12 Feb 2014 22:14:35 +0000 (16:14 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2014 17:18:39 +0000 (09:18 -0800)
After updating Smatch, the following new errors and warnings are reported:

drivers/staging/rtl8188eu/core/rtw_recv.c:368 recvframe_chkmic() warn: variable dereferenced before check 'psecuritypriv' (see line 364)
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:2642 rtw_wps_start() warn: variable dereferenced before check 'pdata' (see line 2636)
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:4461 rtw_dbg_port() error: we previously assumed 'pregpriv' could be null (see line 4453)
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:4473 rtw_dbg_port() error: we previously assumed 'pregpriv' could be null (see line 4469)

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
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c

index 4de98b6224265f60072b2e707977e8ebdaaa1e27..fccea1e270064896b38f618b6bdebbcbcf4b67e2 100644 (file)
@@ -361,16 +361,15 @@ static int recvframe_chkmic(struct adapter *adapter,  union recv_frame *precvfra
                /* calculate mic code */
                if (stainfo != NULL) {
                        if (IS_MCAST(prxattrib->ra)) {
-                               mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0];
-
-                               RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n"));
-
                                if (!psecuritypriv) {
                                        res = _FAIL;
                                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"));
                                        DBG_88E("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n");
                                        goto exit;
                                }
+                               mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0];
+
+                               RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n"));
                        } else {
                                mickey = &stainfo->dot11tkiprxmickey.skey[0];
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n"));
index 7de813986ff09c29103b29f727b3454deda33a95..36910072cf8703e6d63ff5aed280a4d06d76c781 100644 (file)
@@ -2633,13 +2633,13 @@ static int rtw_wps_start(struct net_device *dev,
        struct iw_point *pdata = &wrqu->data;
        u32   u32wps_start = 0;
 
-       ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4);
-       if (ret) {
+       if ((padapter->bDriverStopped) || (pdata == NULL)) {
                ret = -EINVAL;
                goto exit;
        }
 
-       if ((padapter->bDriverStopped) || (pdata == NULL)) {
+       ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4);
+       if (ret) {
                ret = -EINVAL;
                goto exit;
        }
@@ -4450,11 +4450,9 @@ static int rtw_dbg_port(struct net_device *dev,
                        struct registry_priv    *pregpriv = &padapter->registrypriv;
                        /*  0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */
                        /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
-                       if (pregpriv &&
-                           (extra_arg == 0 ||
-                            extra_arg == 1 ||
-                            extra_arg == 2 ||
-                            extra_arg == 3)) {
+                       if (!pregpriv)
+                               break;
+                       if (extra_arg >= 0 && extra_arg <= 3) {
                                pregpriv->rx_stbc = extra_arg;
                                DBG_88E("set rx_stbc =%d\n", pregpriv->rx_stbc);
                        } else {
@@ -4466,7 +4464,9 @@ static int rtw_dbg_port(struct net_device *dev,
                {
                        struct registry_priv    *pregpriv = &padapter->registrypriv;
                        /*  0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */
-                       if (pregpriv && extra_arg >= 0 && extra_arg < 3) {
+                       if (!pregpriv)
+                               break;
+                       if (extra_arg >= 0 && extra_arg < 3) {
                                pregpriv->ampdu_enable = extra_arg;
                                DBG_88E("set ampdu_enable =%d\n", pregpriv->ampdu_enable);
                        } else {