iwlegacy: 3945-rs: fix possible null-pointer dereferences in il3945_rs_get_rate()
PATCH 1/1 iwlegacy: 3945-rs: fix possible null-pointer dereferences in il3945_rs_get_rate()
In this function, il_sta is assigned to rs_sta, and rs_sta is dereferenced at several points. If il_sta is NULL, this can lead to null-pointer dereferences. To fix this issue, add an early check for il_sta and return if it is NULL, consistent with the handling in il3945_rs_tx_status().
--- drivers/net/wireless/intel/iwlegacy/3945-rs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlegacy/3945-rs.c +6 -1
@@ -626,8 +626,13 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,D_RATE ("enter\n" ); +if (!il_sta) { +D_RATE ("leave: No STA il data available!\n" ); +return ; + } +/* Treat uninitialized rate scaling data same as non-existing. */ -if (rs_sta && !rs_sta->il) { +if (!rs_sta->il) {D_RATE ("Rate scaling information not initialized yet.\n" ); il_sta =NULL ; }
Signature · 1 line
2.43.0
Stanislaw Gruszka
maintainerQuoted 18 lines · Tuo Li
In this function,
il_stais assigned tors_sta, andrs_stais dereferenced at several points. Ifil_stais NULL, this can lead to null-pointer dereferences. To fix this issue, add an early check foril_staand return if it is NULL, consistent with the handling inil3945_rs_tx_status().Signed-off-by Tuo Li <[email protected]>--- drivers/net/wireless/intel/iwlegacy/3945-rs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/net/wireless/intel/iwlegacy/3945-rs.c +0
-0@@ -626,8 +626,13 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,D_RATE ("enter\n" );
drivers/net/wireless/intel/iwlegacy/3945-rs.c il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, · line 637
Quoted 10 lines
drivers/net/wireless/intel/iwlegacy/3945-rs.c +6
-1+if (!il_sta) { +D_RATE ("leave: No STA il data available!\n" ); +return ; + } +/* Treat uninitialized rate scaling data same as non-existing. */ -if (rs_sta && !rs_sta->il) { +if (!rs_sta->il) {D_RATE ("Rate scaling information not initialized yet.\n" ); il_sta =NULL ;
Please also change to return here instead of setting il_sta to NULL. And make D_RATE messages similar to il3945_rs_tx_status() i.e. :
if (!il_sta) {
D_RATE("leave: No STA il data to update!\n");
return;
}
/* Treat uninitialized rate scaling data same as non-existing. */
if (!rs_sta->il) {
D_RATE("leave: STA il data uninitialized!\n");
return;
}Thanks
Stanislaw
Stanislaw Gruszka
maintainerQuoted 32 lines · Stanislaw Gruszka
Quoted 18 lines · Tuo Li
In this function,
il_stais assigned tors_sta, andrs_stais dereferenced at several points. Ifil_stais NULL, this can lead to null-pointer dereferences. To fix this issue, add an early check foril_staand return if it is NULL, consistent with the handling inil3945_rs_tx_status().Signed-off-by Tuo Li <[email protected]>--- drivers/net/wireless/intel/iwlegacy/3945-rs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/net/wireless/intel/iwlegacy/3945-rs.c +0
-0@@ -626,8 +626,13 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,D_RATE ("enter\n" );drivers/net/wireless/intel/iwlegacy/3945-rs.c il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, · line 637
Quoted 10 lines
drivers/net/wireless/intel/iwlegacy/3945-rs.c +6
-1+if (!il_sta) { +D_RATE ("leave: No STA il data available!\n" ); +return ; + } +/* Treat uninitialized rate scaling data same as non-existing. */ -if (rs_sta && !rs_sta->il) { +if (!rs_sta->il) {D_RATE ("Rate scaling information not initialized yet.\n" ); il_sta =NULL ;Please also change to return here instead of setting
il_stato NULL. And makeD_RATEmessages similar toil3945_rs_tx_status()i.e. :
Quoted 10 lines
if (!il_sta) {
D_RATE("leave: No STA il data to update!\n");
return;
}
/* Treat uninitialized rate scaling data same as non-existing. */
if (!rs_sta->il) {
D_RATE("leave: STA il data uninitialized!\n");
return;
}Please also add 'wifi:' prefix to the patch title.
Thanks
Stanislaw
Quoted 45 lines · Stanislaw Gruszka
Quoted 32 lines · Stanislaw Gruszka
Quoted 18 lines · Tuo Li
In this function,
il_stais assigned tors_sta, andrs_stais dereferenced at several points. Ifil_stais NULL, this can lead to null-pointer dereferences. To fix this issue, add an early check foril_staand return if it is NULL, consistent with the handling inil3945_rs_tx_status().Signed-off-by Tuo Li <[email protected]>--- drivers/net/wireless/intel/iwlegacy/3945-rs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/net/wireless/intel/iwlegacy/3945-rs.c +0
-0@@ -626,8 +626,13 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,D_RATE ("enter\n" );drivers/net/wireless/intel/iwlegacy/3945-rs.c il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, · line 637
Quoted 10 lines
drivers/net/wireless/intel/iwlegacy/3945-rs.c +6
-1+if (!il_sta) { +D_RATE ("leave: No STA il data available!\n" ); +return ; + } +/* Treat uninitialized rate scaling data same as non-existing. */ -if (rs_sta && !rs_sta->il) { +if (!rs_sta->il) {D_RATE ("Rate scaling information not initialized yet.\n" ); il_sta =NULL ;Please also change to return here instead of setting
il_stato NULL. And makeD_RATEmessages similar toil3945_rs_tx_status()i.e. :Quoted 10 lines
if (!il_sta) { D_RATE("leave: No STA il data to update!\n"); return; } /* Treat uninitialized rate scaling data same as non-existing. */ if (!rs_sta->il) { D_RATE("leave: STA il data uninitialized!\n"); return; }
Quoted 4 lines
Please also add 'wifi:' prefix to the patch title.
Thanks
Stanislaw
Hi Stanislaw,
Thank you for your reply. I will update the patch according to your suggestions and submit a v2.
Sincerely,
Tuo