From patchwork Mon Sep 10 04:46:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1429771 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6E3BF4025E for ; Mon, 10 Sep 2012 04:46:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803Ab2IJEqs (ORCPT ); Mon, 10 Sep 2012 00:46:48 -0400 Received: from mail-qa0-f53.google.com ([209.85.216.53]:62757 "EHLO mail-qa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750718Ab2IJEqr (ORCPT ); Mon, 10 Sep 2012 00:46:47 -0400 Received: by qaas11 with SMTP id s11so680062qaa.19 for ; Sun, 09 Sep 2012 21:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=agCHUCzL1H0ET5Gd9NxqOna/IPBIIYL5AK+50AYWWaA=; b=LtYlG3rDxq6qkEjjbUb6ue9gZhXcNM8t7KE+R6L4KlB4tTatXEneL8GGvc/qawwzpN be6dXjvUORqbcmpz5qwGBgYDJSlRlS6xg5QH/RRkJtZFKXMYx5fVLzSPIeR2kMC2vfBr 9TlglqTA+n8XkrpMPj4KaRWk+87sUmjnPJxaNk9T/tBIVz4LkkMs+1+EIytqexH2szWN ctMm6AKLokEzbXYCTLuVpLpLXSC5QIDL0ev8iuH56IG89NykyNTsvyDpSY/SKz5hQ8NK TZafMXUj+fH1ibUVw1rtFlZu4GSKAmkGRYS1UeoyP/n0Oyi7JqPgh6hkFlf6JKkG1CG8 Tnzg== MIME-Version: 1.0 Received: by 10.224.184.20 with SMTP id ci20mr14712989qab.26.1347252406814; Sun, 09 Sep 2012 21:46:46 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Sun, 9 Sep 2012 21:46:46 -0700 (PDT) Date: Mon, 10 Sep 2012 12:46:46 +0800 Message-ID: Subject: [PATCH] rndis_wlan: move the dereference below the NULL test From: Wei Yongjun To: jussi.kivilinna@mbnet.fi, linville@tuxdriver.com Cc: yongjun_wei@trendmicro.com.cn, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Wei Yongjun The dereference should be moved below the NULL test. spatch with a semantic match is used to found this. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun --- drivers/net/wireless/rndis_wlan.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 7a4ae9e..de2a673 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -1946,12 +1946,19 @@ static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm) static int rndis_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) { - struct net_device *dev = request->wdev->netdev; - struct usbnet *usbdev = netdev_priv(dev); - struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); + struct net_device *dev; + struct usbnet *usbdev; + struct rndis_wlan_private *priv; int ret; int delay = SCAN_DELAY_JIFFIES; + if (!request) + return -EINVAL; + + dev = request->wdev->netdev; + usbdev = netdev_priv(dev); + priv = get_rndis_wlan_priv(usbdev); + netdev_dbg(usbdev->net, "cfg80211.scan\n"); /* Get current bssid list from device before new scan, as new scan @@ -1959,9 +1966,6 @@ static int rndis_scan(struct wiphy *wiphy, */ rndis_check_bssid_list(usbdev, NULL, NULL); - if (!request) - return -EINVAL; - if (priv->scan_request && priv->scan_request != request) return -EBUSY;