From patchwork Thu Jun 23 17:57:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis de Bethencourt X-Patchwork-Id: 9195687 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4503608A7 for ; Thu, 23 Jun 2016 17:57:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C71702845F for ; Thu, 23 Jun 2016 17:57:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBC3928467; Thu, 23 Jun 2016 17:57:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A2FC2845F for ; Thu, 23 Jun 2016 17:57:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751380AbcFWR5R (ORCPT ); Thu, 23 Jun 2016 13:57:17 -0400 Received: from lists.s-osg.org ([54.187.51.154]:33485 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751001AbcFWR5Q (ORCPT ); Thu, 23 Jun 2016 13:57:16 -0400 Received: from snow.seri.co.uk (cpc9-slam5-2-0-cust824.2-4.cable.virginm.net [81.108.163.57]) by lists.s-osg.org (Postfix) with ESMTPSA id 75E08E2745; Thu, 23 Jun 2016 10:58:17 -0700 (PDT) From: Luis de Bethencourt To: linux-kernel@vger.kernel.org Cc: johnny.kim@atmel.com, austin.shin@atmel.com, chris.park@atmel.com, tony.cho@atmel.com, glen.lee@atmel.com, leo.kim@atmel.com, gregkh@linuxfoundation.org, linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, Luis de Bethencourt Subject: [PATCH] staging: wilc1000: arrays can't be NULL Date: Thu, 23 Jun 2016 18:57:09 +0100 Message-Id: <1466704629-26084-1-git-send-email-luisbg@osg.samsung.com> X-Mailer: git-send-email 2.5.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Hi, I am aware this patch gives a few checkpatch.pl warnings about lines being over 80 characters. Fixing that would be a completely different issue, and a lengthy one since the file has loads of them. Hopefully somebody else picks that up. Maybe I should send a hit to the kernelnewbies mailing list :) Thanks, Luis drivers/staging/wilc1000/host_interface.c | 38 ++++++++++------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 3 +- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 9535842..7d5745a 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1231,17 +1231,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; } } } @@ -1250,20 +1247,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; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 51aff4f..3ddfa4a 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -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;