LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] staging: rtl8188eu: rtw_mlme.c: fix sparse warning
@ 2014-12-29 5:47 Serguey Parkhomovsky
2014-12-29 6:20 ` Larry Finger
0 siblings, 1 reply; 2+ messages in thread
From: Serguey Parkhomovsky @ 2014-12-29 5:47 UTC (permalink / raw)
To: Greg Kroah-Hartman, navin patidar, Larry Finger, Elena Oat,
Tim Jester-Pfadt
Cc: devel, linux-kernel
Fixes the following sparse warning for rtw_mlme.c:
drivers/staging/rtl8188eu/core/rtw_mlme.c:810:9: warning: context imbalance in 'rtw_free_assoc_resources' - different lock contexts for basic block
Signed-off-by: Serguey Parkhomovsky <sergueyparkhomovsky@gmail.com>
---
drivers/staging/rtl8188eu/core/rtw_mlme.c | 37 ++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index d4632da..a47717a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -755,12 +755,30 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv)
spin_unlock_bh(&scan_queue->lock);
}
+static void rtw_free_current_network(struct adapter *adapter)
+{
+ struct wlan_network *pwlan = NULL;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ struct wlan_network *tgt_network = &pmlmepriv->cur_network;
+
+ pwlan = rtw_find_network(&pmlmepriv->scanned_queue,
+ tgt_network->network.MacAddress);
+ if (pwlan)
+ pwlan->fixed = false;
+ else
+ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+ ("rtw_free_assoc_resources:pwlan==NULL\n\n"));
+
+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) &&
+ (adapter->stapriv.asoc_sta_count == 1))
+ rtw_free_network_nolock(pmlmepriv, pwlan);
+}
+
/*
*rtw_free_assoc_resources: the caller has to lock pmlmepriv->lock
*/
void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue)
{
- struct wlan_network *pwlan = NULL;
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
struct sta_priv *pstapriv = &adapter->stapriv;
struct wlan_network *tgt_network = &pmlmepriv->cur_network;
@@ -793,20 +811,13 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue)
rtw_init_bcmc_stainfo(adapter);
}
- if (lock_scanned_queue)
+ if (lock_scanned_queue) {
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
-
- pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
- if (pwlan)
- pwlan->fixed = false;
- else
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_assoc_resources:pwlan==NULL\n\n"));
-
- if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1)))
- rtw_free_network_nolock(pmlmepriv, pwlan);
-
- if (lock_scanned_queue)
+ rtw_free_current_network(adapter);
spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
+ } else
+ rtw_free_current_network(adapter);
+
pmlmepriv->key_mask = 0;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: rtl8188eu: rtw_mlme.c: fix sparse warning
2014-12-29 5:47 [PATCH] staging: rtl8188eu: rtw_mlme.c: fix sparse warning Serguey Parkhomovsky
@ 2014-12-29 6:20 ` Larry Finger
0 siblings, 0 replies; 2+ messages in thread
From: Larry Finger @ 2014-12-29 6:20 UTC (permalink / raw)
To: Serguey Parkhomovsky, Greg Kroah-Hartman, navin patidar,
Elena Oat, Tim Jester-Pfadt
Cc: devel, linux-kernel
On 12/28/2014 11:47 PM, Serguey Parkhomovsky wrote:
> Fixes the following sparse warning for rtw_mlme.c:
>
> drivers/staging/rtl8188eu/core/rtw_mlme.c:810:9: warning: context imbalance in 'rtw_free_assoc_resources' - different lock contexts for basic block
>
> Signed-off-by: Serguey Parkhomovsky <sergueyparkhomovsky@gmail.com>
> ---
> drivers/staging/rtl8188eu/core/rtw_mlme.c | 37 ++++++++++++++++++++-----------
> 1 file changed, 24 insertions(+), 13 deletions(-)
Are these many changes needed just because Sparse is not smart enough to
understand that the following does not really have a context imbalance:
if (lock_scanned_queue)
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
.....
.....
if (lock_scanned_queue)
spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
Nothing in the middle touches lock_scanned_queue, thus if the spin lock and
unlock operations will be paired. That is all that is important. The fact that
some tool objects to this construct means that the tool is broken, not the code.
In my mind, Sparse warnings/errors/checks are in place to alert you to a
possible problem. If they point to white space issues, then you fix them. If
they point to lines that are too long, then you see if you can shorten them
without harming the readability. In any case, judgement should be used before
blindly trying to silence the warning.
For those reasons, NACK.
Larry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-29 6:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-29 5:47 [PATCH] staging: rtl8188eu: rtw_mlme.c: fix sparse warning Serguey Parkhomovsky
2014-12-29 6:20 ` Larry Finger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).