wifi: iwlegacy: 3945-rs: add a defensive WARN_ON_ONCE for il_sta in il3945_rs_get_rate()
PATCH v3 1/1 wifi: iwlegacy: 3945-rs: add a defensive WARN_ON_ONCE for il_sta in il3945_rs_get_rate()
In this function, il_sta is not expected to be NULL. Add a defensive WARN_ON_ONCE() to catch this unexpected condition and aid debugging.
---
v3:
* Replace plain NULL check with WARN_ON_ONCE() and update subject to better reflect defensive nature of the check.
Thanks to Johannes Berg and Stanislaw Gruszka for helpful advice.
v2:
* Return early for uninitialized STA il data and align D_RATE messages with il3945_rs_tx_status(). Add a wifi: prefix to the patch title. Thanks to Stanislaw Gruszka for the helpful advice.
--- drivers/net/wireless/intel/iwlegacy/3945-rs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/iwlegacy/3945-rs.c +3 -0
@@ -626,6 +626,9 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,D_RATE ("enter\n" ); +if (WARN_ON_ONCE (!il_sta)) +return ; +/* Treat uninitialized rate scaling data same as non-existing. */ if (rs_sta && !rs_sta->il) {D_RATE ("Rate scaling information not initialized yet.\n" );
Signature · 1 line
2.43.0
Stanislaw Gruszka
maintainerHi Tuo,
Quoted 22 lines · Tuo Li
In this function,
il_stais not expected to be NULL. Add a defensiveWARN_ON_ONCE()to catch this unexpected condition and aid debugging.Signed-off-by Tuo Li <[email protected]>---
v3:
* Replace plain NULL check withWARN_ON_ONCE()and update subject to better reflect defensive nature of the check.
Thanks to Johannes Berg and Stanislaw Gruszka for helpful advice.
v2:
* Return early for uninitialized STA il data and alignD_RATEmessages withil3945_rs_tx_status(). Add a wifi: prefix to the patch title. Thanks to Stanislaw Gruszka for the helpful advice.--- drivers/net/wireless/intel/iwlegacy/3945-rs.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/wireless/intel/iwlegacy/3945-rs.c +0
-0
drivers/net/wireless/intel/iwlegacy/3945-rs.c il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, · line 631
Quoted 6 lines
drivers/net/wireless/intel/iwlegacy/3945-rs.c +3
-0@@ -626,6 +626,9 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,D_RATE ("enter\n" ); +if (WARN_ON_ONCE (!il_sta)) +return ; +
Sorry for giving you wrong advice before, but after examining related code I agree with Johannes the il_sta can not be NULL.
Now, I think we should just remove il_sta/rs_sta pointer check.
Regards
Stanislaw
Hi Stanislaw,
Quoted 37 lines · Stanislaw Gruszka
Hi Tuo,
Quoted 22 lines · Tuo Li
In this function,
il_stais not expected to be NULL. Add a defensiveWARN_ON_ONCE()to catch this unexpected condition and aid debugging.Signed-off-by Tuo Li <[email protected]>---
v3:
* Replace plain NULL check withWARN_ON_ONCE()and update subject to better reflect defensive nature of the check.
Thanks to Johannes Berg and Stanislaw Gruszka for helpful advice.
v2:
* Return early for uninitialized STA il data and alignD_RATEmessages withil3945_rs_tx_status(). Add a wifi: prefix to the patch title. Thanks to Stanislaw Gruszka for the helpful advice.--- drivers/net/wireless/intel/iwlegacy/3945-rs.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/wireless/intel/iwlegacy/3945-rs.c +0
-0drivers/net/wireless/intel/iwlegacy/3945-rs.c il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, · line 631
Quoted 6 lines
drivers/net/wireless/intel/iwlegacy/3945-rs.c +3
-0@@ -626,6 +626,9 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,D_RATE ("enter\n" ); +if (WARN_ON_ONCE (!il_sta)) +return ; +Sorry for giving you wrong advice before, but after examining related code I agree with Johannes the
il_stacan not be NULL.
Now, I think we should just remove il_sta/rs_sta pointer check.
Quoted 2 lines
Regards
Stanislaw
Thanks for the follow-up and your patience. I appreciate you taking another look at the code.
Just to confirm, would you like me to submit a v4 patch that removes the unnecessary il_sta / rs_sta checks, e.g.:
in il3945_rs_get_rate():
- if (rs_sta && !rs_sta->il) {
+ if (!rs_sta->il) {
and in il3945_rs_tx_status():
- if (!il_sta) {
- D_RATE("leave: No STA il data to update!\n");
- return;
- }
If a v4 is not needed, I'm also fine with dropping this patch series.
Best regards,
Tuo
Stanislaw Gruszka
maintainerHi
Quoted 21 lines · Tuo Li
Quoted 6 lines
Sorry for giving you wrong advice before, but after examining related code I agree with Johannes the
il_stacan not be NULL.
Now, I think we should just remove il_sta/rs_sta pointer check.Regards
StanislawThanks for the follow-up and your patience. I appreciate you taking another look at the code.
Just to confirm, would you like me to submit a v4 patch that removes the unnecessary
il_sta/rs_stachecks, e.g.:in
il3945_rs_get_rate():- if (
rs_sta&& !rs_sta->il) {
+ if (!rs_sta->il) {and in
il3945_rs_tx_status():- if (!il_sta) {
Review
Quoted 3 lines
(quoted diff) +0
-3- D_RATE("leave: No STA il data to update!\n"); - return; - }
Yes, please post those changes as v4.
Thanks
Stanislaw
Hi Stanislaw,
Quoted 29 lines · Stanislaw Gruszka
Hi
Quoted 21 lines · Tuo Li
Quoted 6 lines
Sorry for giving you wrong advice before, but after examining related code I agree with Johannes the
il_stacan not be NULL.
Now, I think we should just remove il_sta/rs_sta pointer check.Regards
StanislawThanks for the follow-up and your patience. I appreciate you taking another look at the code.
Just to confirm, would you like me to submit a v4 patch that removes the unnecessary
il_sta/rs_stachecks, e.g.:in
il3945_rs_get_rate():- if (
rs_sta&& !rs_sta->il) {
+ if (!rs_sta->il) {and in
il3945_rs_tx_status():- if (!il_sta) {
Review
Quoted 3 lines
(quoted diff) +0
-3- D_RATE("leave: No STA il data to update!\n"); - return; - }
Quoted 4 lines
Yes, please post those changes as v4.
Thanks
Stanislaw
Thanks for your reply.
I will post these changes and submit a v4 patch shortly.
Best regards,
Tuo