From patchwork Fri Aug 25 08:43:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9921429 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 230D1600C5 for ; Fri, 25 Aug 2017 08:44:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F84426E74 for ; Fri, 25 Aug 2017 08:44:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0388820952; Fri, 25 Aug 2017 08:44:41 +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, UNPARSEABLE_RELAY autolearn=ham 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 A7A7020952 for ; Fri, 25 Aug 2017 08:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755111AbdHYIoV (ORCPT ); Fri, 25 Aug 2017 04:44:21 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:17794 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755012AbdHYIoT (ORCPT ); Fri, 25 Aug 2017 04:44:19 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7P8iABd012742 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2017 08:44:10 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v7P8i9A2000727 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2017 08:44:10 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v7P8i98j024329; Fri, 25 Aug 2017 08:44:09 GMT Received: from mwanda (/41.202.241.62) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 25 Aug 2017 01:44:08 -0700 Date: Fri, 25 Aug 2017 11:43:51 +0300 From: Dan Carpenter To: Kalle Valo , Prameela Rani Garnepudi Cc: Amitkumar Karwar , Karun Eagalapati , Andrew Zaborowski , linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 1/2] rsi: missing unlocks on error paths Message-ID: <20170825082645.z2hiotefhzizb7sr@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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 There is a missing unlock if rsi_find_sta() fails in rsi_mac80211_ampdu_action() or if we hit the -EINVAL path in rsi_mac80211_sta_add(). Fixes: 3528608f3a79 ("rsi: handle station connection in AP mode") Signed-off-by: Dan Carpenter diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c index 8b983d03f2da..25331aa16e8e 100644 --- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c +++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c @@ -906,7 +906,8 @@ static int rsi_mac80211_ampdu_action(struct ieee80211_hw *hw, rsta = rsi_find_sta(common, sta->addr); if (!rsta) { rsi_dbg(ERR_ZONE, "No station mapped\n"); - return 0; + status = 0; + goto unlock; } sta_id = rsta->sta_id; } @@ -974,6 +975,7 @@ static int rsi_mac80211_ampdu_action(struct ieee80211_hw *hw, break; } +unlock: mutex_unlock(&common->mutex); return status; } @@ -1202,6 +1204,7 @@ static int rsi_mac80211_sta_add(struct ieee80211_hw *hw, struct rsi_common *common = adapter->priv; bool sta_exist = false; struct rsi_sta *rsta; + int status = 0; rsi_dbg(INFO_ZONE, "Station Add: %pM\n", sta->addr); @@ -1215,8 +1218,8 @@ static int rsi_mac80211_sta_add(struct ieee80211_hw *hw, /* Check if max stations reached */ if (common->num_stations >= common->max_stations) { rsi_dbg(ERR_ZONE, "Reject: Max Stations exists\n"); - mutex_unlock(&common->mutex); - return -EOPNOTSUPP; + status = -EOPNOTSUPP; + goto unlock; } for (cnt = 0; cnt < common->max_stations; cnt++) { rsta = &common->stations[cnt]; @@ -1241,7 +1244,8 @@ static int rsi_mac80211_sta_add(struct ieee80211_hw *hw, rsi_dbg(ERR_ZONE, "%s: Some problem reaching here...\n", __func__); - return -EINVAL; + status = -EINVAL; + goto unlock; } rsta = &common->stations[sta_idx]; rsta->sta = sta; @@ -1289,9 +1293,10 @@ static int rsi_mac80211_sta_add(struct ieee80211_hw *hw, } } +unlock: mutex_unlock(&common->mutex); - return 0; + return status; } /**