Commit 4562d224 authored by Luis de Bethencourt's avatar Luis de Bethencourt Committed by Greg Kroah-Hartman

staging: wilc1000: arrays can't be NULL

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: default avatarLuis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a5c84b2f
...@@ -1237,17 +1237,14 @@ static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif, ...@@ -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++) { for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
if ((hif_drv->usr_scan_req.net_info[i].bssid) && if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid,
(pstrNetworkInfo->bssid)) { pstrNetworkInfo->bssid, 6) == 0) {
if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid, if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) {
pstrNetworkInfo->bssid, 6) == 0) { goto done;
if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) { } else {
goto done; hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi;
} else { bNewNtwrkFound = false;
hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi; break;
bNewNtwrkFound = false;
break;
}
} }
} }
} }
...@@ -1256,20 +1253,17 @@ static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif, ...@@ -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) { 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; 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 && memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid,
pstrNetworkInfo->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; pstrNetworkInfo->new_network = true;
pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo); pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
hif_drv->usr_scan_req.arg, hif_drv->usr_scan_req.arg,
pJoinParams); pJoinParams);
}
} }
} else { } else {
pstrNetworkInfo->new_network = false; pstrNetworkInfo->new_network = false;
......
...@@ -625,8 +625,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) ...@@ -625,8 +625,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
for (i = 0; i < request->n_ssids; i++) { for (i = 0; i < request->n_ssids; i++) {
if (request->ssids[i].ssid && if (request->ssids[i].ssid_len != 0) {
request->ssids[i].ssid_len != 0) {
strHiddenNetwork.net_info[i].ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL); 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); 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; strHiddenNetwork.net_info[i].ssid_len = request->ssids[i].ssid_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment