netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] iwlwifi: rs: remove superfluous check
@ 2016-05-17 23:31 Heinrich Schuchardt
  2016-05-19  8:27 ` Coelho, Luciano
  0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2016-05-17 23:31 UTC (permalink / raw)
  To: Johannes Berg, Emmanuel Grumbach, Luca Coelho, Kalle Valo
  Cc: Intel Linux Wireless, Eyal Shapira, Gregory Greenman,
	Alexander Bondar, linux-wireless, netdev, linux-kernel,
	Heinrich Schuchardt

If we dereference a variable anyway in other parts of the code,
there is no need to check against NULL in a single place.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index 81dd2f6..bab01ea 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -2867,7 +2867,7 @@ static void rs_get_rate(void *mvm_r, struct ieee80211_sta *sta, void *mvm_sta,
 	/* TODO: handle rate_idx_mask and rate_idx_mcs_mask */
 
 	/* Treat uninitialized rate scaling data same as non-existing. */
-	if (lq_sta && !lq_sta->pers.drv) {
+	if (!lq_sta->pers.drv) {
 		IWL_DEBUG_RATE(mvm, "Rate scaling not initialized yet.\n");
 		mvm_sta = NULL;
 	}
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] iwlwifi: rs: remove superfluous check
  2016-05-17 23:31 [PATCH 1/1] iwlwifi: rs: remove superfluous check Heinrich Schuchardt
@ 2016-05-19  8:27 ` Coelho, Luciano
  0 siblings, 0 replies; 2+ messages in thread
From: Coelho, Luciano @ 2016-05-19  8:27 UTC (permalink / raw)
  To: kvalo@codeaurora.org, xypron.glpk@gmx.de, Berg, Johannes,
	Grumbach, Emmanuel
  Cc: linuxwifi, eyal@wizery.com, netdev@vger.kernel.org,
	linux-wireless@vger.kernel.org, Greenman, Gregory,
	Bondar, Alexander, linux-kernel@vger.kernel.org

On Wed, 2016-05-18 at 01:31 +0200, Heinrich Schuchardt wrote:
> If we dereference a variable anyway in other parts of the code,
> there is no need to check against NULL in a single place.

NACK.  This is not true.

If lq_sta is NULL, it means that mvm_sta is also NULL.  Then we call
the rate_control_send with mvm_sta == NULL:

	if (rate_control_send_low(sta, mvm_sta, txrc))
		return;

The rate_control_send_low() function looks like this:


bool rate_control_send_low(struct ieee80211_sta *pubsta,
			   void *priv_sta,
			   struct ieee80211_tx_rate_control *txrc)
{
[...]
	if (!pubsta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
[...]
		return true;
	}
[...]
}


Which means that if priv_sta (aka mvm_sta) is NULL, we will return
without running the rest of rs_get_rate() where lq_sta is accessed
without checks.

I admit that the rs_get_rate() function is a bit hard to read, but
removing the lq_sta check as you did doesn't help, but makes things
worse.

--
Cheers,
Luca.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-19  8:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-17 23:31 [PATCH 1/1] iwlwifi: rs: remove superfluous check Heinrich Schuchardt
2016-05-19  8:27 ` Coelho, Luciano

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).