staging: wilc1000: arrays can't be NULL
authorLuis de Bethencourt <luisbg@osg.samsung.com>
Thu, 23 Jun 2016 17:57:09 +0000 (18:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2016 21:41:18 +0000 (14:41 -0700)
hif_drv->usr_scan_req.net.net_info[i] contains found_net_info structs
which have the following element:
u8 bssid[6];

pstrNetworkInfo, of type network_info, also contains an u8 array named
bssid.

request->ssids is an array of cfg80211_ssid structs. Making ssid:
u8 ssid[IEEE80211_MAX_SSID_LEN];

In these 3 cases the arrays are being checked against NULL, which can't
happen. Removing the checks since they will always be true.

Found with smatch:
drivers/staging/wilc1000/host_interface.c:1234 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'hif_drv->usr_scan_req.net_info[i].bssid'
drivers/staging/wilc1000/host_interface.c:1235 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'pstrNetworkInfo->bssid'
drivers/staging/wilc1000/host_interface.c:1253 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid'
drivers/staging/wilc1000/host_interface.c:1254 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'pstrNetworkInfo->bssid'

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/host_interface.c
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c

index bee693ab2c1fd28081be41fda93b496c6f11764b..0b1760cba6e35a77fc391f44f9cfc7c263b9e254 100644 (file)
@@ -1237,17 +1237,14 @@ static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
                }
 
                for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
-                       if ((hif_drv->usr_scan_req.net_info[i].bssid) &&
-                           (pstrNetworkInfo->bssid)) {
-                               if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid,
-                                          pstrNetworkInfo->bssid, 6) == 0) {
-                                       if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) {
-                                               goto done;
-                                       } else {
-                                               hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi;
-                                               bNewNtwrkFound = false;
-                                               break;
-                                       }
+                       if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid,
+                                  pstrNetworkInfo->bssid, 6) == 0) {
+                               if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) {
+                                       goto done;
+                               } else {
+                                       hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi;
+                                       bNewNtwrkFound = false;
+                                       break;
                                }
                        }
                }
@@ -1256,20 +1253,17 @@ static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
                        if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
                                hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].rssi = pstrNetworkInfo->rssi;
 
-                               if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid &&
-                                   pstrNetworkInfo->bssid) {
-                                       memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid,
-                                              pstrNetworkInfo->bssid, 6);
+                               memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid,
+                                      pstrNetworkInfo->bssid, 6);
 
-                                       hif_drv->usr_scan_req.rcvd_ch_cnt++;
+                               hif_drv->usr_scan_req.rcvd_ch_cnt++;
 
-                                       pstrNetworkInfo->new_network = true;
-                                       pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
+                               pstrNetworkInfo->new_network = true;
+                               pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
 
-                                       hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
-                                                                         hif_drv->usr_scan_req.arg,
-                                                                         pJoinParams);
-                               }
+                               hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
+                                                                 hif_drv->usr_scan_req.arg,
+                                                                 pJoinParams);
                        }
                } else {
                        pstrNetworkInfo->new_network = false;
index 51aff4ff7d7c37aafca0b08adb1e9375287b6072..3ddfa4aecb7a9383b9bd0f44a1c5abf51b0b5a5f 100644 (file)
@@ -625,8 +625,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 
 
                        for (i = 0; i < request->n_ssids; i++) {
-                               if (request->ssids[i].ssid &&
-                                   request->ssids[i].ssid_len != 0) {
+                               if (request->ssids[i].ssid_len != 0) {
                                        strHiddenNetwork.net_info[i].ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
                                        memcpy(strHiddenNetwork.net_info[i].ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
                                        strHiddenNetwork.net_info[i].ssid_len = request->ssids[i].ssid_len;