mt76: mt7915: fix unused 'mode' variable
Subsystems (5)
PATCH 1/2 mt76: mt7915: fix unused 'mode' variable
From: Arnd Bergmann <[email protected]>
clang points out a possible corner case in the mt7915_tm_set_tx_cont() function if called with invalid arguments:
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:593:2: warning: variable 'mode' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
default:
^~~~~~~
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:597:13: note: uninitialized use occurs here
rateval = mode << 6 | rate_idx;
^~~~
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:506:37: note: initialize the variable 'mode' to silence this warning
u8 rate_idx = td->tx_rate_idx, mode;
^Change it to return an error instead of continuing with invalid data here.
--- drivers/net/wireless/mediatek/mt76/mt7915/testmode.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c +2 -0
@@ -543,6 +543,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) tx_cont->bw =CMD_CBW_20MHZ ;break ;default : +return -EINVAL ;break ; }
@@ -591,6 +592,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) mode =MT_PHY_TYPE_HE_MU ;break ;default : +return -EINVAL ;break ; }
Signature · 7 lines
2.29.2 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 2/2 mt76: mt7921: remove incorrect error handling
From: Arnd Bergmann <[email protected]>
Clang points out a mistake in the error handling in mt7921_mcu_tx_rate_report(), which tries to dereference a pointer that cannot be initialized because of the error that is being handled:
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:409:3: warning: variable 'stats' is uninitialized when used here [-Wuninitialized]
stats->tx_rate = rate;
^~~~~
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:401:32: note: initialize the variable 'stats' to silence this warning
struct mt7921_sta_stats *stats;
^Just remove the obviously incorrect line.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1 -3
@@ -405,10 +405,8 @@ mt7921_mcu_tx_rate_report(struct mt7921_dev *dev, struct sk_buff *skb,if (wlan_idx >=MT76_N_WCIDS )return ; wcid =rcu_dereference (dev->mt76.wcid[wlan_idx]); -if (!wcid) { - stats->tx_rate = rate; +if (!wcid)return ; - } msta = container_of(wcid, struct mt7921_sta, wcid); stats = &msta->stats;
Signature · 7 lines
2.29.2 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 15 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang points out a possible corner case in the
mt7915_tm_set_tx_cont()function if called with invalid arguments:
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:593:2: warning: variable 'mode' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]default: ^~~~~~~ drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:597:13: note: uninitialized use occurs here rateval = mode << 6 | rate_idx; ^~~~ drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:506:37: note: initialize the variable 'mode' to silence this warning u8 rate_idx = td->tx_rate_idx, mode; ^
Quoted 5 lines
Change it to return an error instead of continuing with invalid data here.
Fixes 3f0caa3cbf94 ("mt76: mt7915: add support for continuous tx in testmode")Signed-off-by Arnd Bergmann <[email protected]>
Felix, can I take these two to wireless-drivers? An ack would be good.
Signature · 8 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 29 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang points out a possible corner case in the
mt7915_tm_set_tx_cont()function if called with invalid arguments:
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:593:2: warning: variable 'mode' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]default: ^~~~~~~ drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:597:13: note: uninitialized use occurs here rateval = mode << 6 | rate_idx; ^~~~ drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:506:37: note: initialize the variable 'mode' to silence this warning u8 rate_idx = td->tx_rate_idx, mode; ^Change it to return an error instead of continuing with invalid data here.
Fixes 3f0caa3cbf94 ("mt76: mt7915: add support for continuous tx in testmode")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7915/testmode.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/wireless/mediatek/mt76/mt7915/testmode.c +0
-0
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) · line 546
Quoted 4 lines
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c +1
-0@@ -543,6 +543,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) tx_cont->bw =CMD_CBW_20MHZ ;break ;default : +return -EINVAL ;
Remove the break if we are adding a return?
Quoted 14 lines
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c +1
-0break ; }@@ -591,6 +592,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) mode =MT_PHY_TYPE_HE_MU ;break ;default : +return -EINVAL ;break ; }Signature · 1 line
2.29.2
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 2/2] mt76: mt7921: remove incorrect error handling
In reply to Arnd BergmannQuoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Clang points out a mistake in the error handling in
mt7921_mcu_tx_rate_report(), which tries to dereference a pointer that cannot be initialized because of the error that is being handled:
Quoted 7 lines
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:409:3: warning: variable 'stats' is uninitialized when used here [-Wuninitialized]stats->tx_rate = rate; ^~~~~ drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:401:32: note: initialize the variable 'stats' to silence this warning struct mt7921_sta_stats *stats; ^Just remove the obviously incorrect line.
Yeah, looks like perhaps a small mistake from when the driver was introduced. Thanks for the patch!
Quoted 26 lines
Fixes 1c099ab44727 ("mt76: mt7921: add MCU support")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1
-4@@ -405,10 +405,8 @@ mt7921_mcu_tx_rate_report(struct mt7921_dev *dev, struct sk_buff *skb,if (wlan_idx >=MT76_N_WCIDS )return ; wcid =rcu_dereference (dev->mt76.wcid[wlan_idx]); -if (!wcid) { - stats->tx_rate = rate; +if (!wcid)return ; - } msta = container_of(wcid, struct mt7921_sta, wcid); stats = &msta->stats; --2.29.2
Signature · 7 lines
Thanks, ~Nick Desaulniers _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 2/2] mt76: mt7921: remove incorrect error handling
In reply to Arnd BergmannQuoted 12 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Clang points out a mistake in the error handling in
mt7921_mcu_tx_rate_report(), which tries to dereference a pointer that cannot be initialized because of the error that is being handled:
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:409:3: warning: variable 'stats' is uninitialized when used here [-Wuninitialized]stats->tx_rate = rate; ^~~~~ drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:401:32: note: initialize the variable 'stats' to silence this warning struct mt7921_sta_stats *stats; ^
Quoted 5 lines
Just remove the obviously incorrect line.
Fixes 1c099ab44727 ("mt76: mt7921: add MCU support")Signed-off-by Arnd Bergmann <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>
Patch applied to wireless-drivers.git, thanks.
fb5fabb192b2 mt76: mt7921: remove incorrect error handling
Signature · 9 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 15 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang points out a possible corner case in the
mt7915_tm_set_tx_cont()function if called with invalid arguments:
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:593:2: warning: variable 'mode' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]default: ^~~~~~~ drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:597:13: note: uninitialized use occurs here rateval = mode << 6 | rate_idx; ^~~~ drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:506:37: note: initialize the variable 'mode' to silence this warning u8 rate_idx = td->tx_rate_idx, mode; ^
Quoted 5 lines
Change it to return an error instead of continuing with invalid data here.
Fixes 3f0caa3cbf94 ("mt76: mt7915: add support for continuous tx in testmode")Signed-off-by Arnd Bergmann <[email protected]>
Please remove the break and send v2.
Patch set to Changes Requested.
Signature · 9 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 2/2] mt76: mt7921: remove incorrect error handling
In reply to Arnd BergmannQuoted 12 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Clang points out a mistake in the error handling in
mt7921_mcu_tx_rate_report(), which tries to dereference a pointer that cannot be initialized because of the error that is being handled:
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:409:3: warning: variable 'stats' is uninitialized when used here [-Wuninitialized]stats->tx_rate = rate; ^~~~~ drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:401:32: note: initialize the variable 'stats' to silence this warning struct mt7921_sta_stats *stats; ^
Quoted 5 lines
Just remove the obviously incorrect line.
Fixes 1c099ab44727 ("mt76: mt7921: add MCU support")Signed-off-by Arnd Bergmann <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>
Patch applied to wireless-drivers.git, thanks.
fb5fabb192b2 mt76: mt7921: remove incorrect error handling
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 15 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang points out a possible corner case in the
mt7915_tm_set_tx_cont()function if called with invalid arguments:
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:593:2: warning: variable 'mode' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]default: ^~~~~~~ drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:597:13: note: uninitialized use occurs here rateval = mode << 6 | rate_idx; ^~~~ drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:506:37: note: initialize the variable 'mode' to silence this warning u8 rate_idx = td->tx_rate_idx, mode; ^
Quoted 5 lines
Change it to return an error instead of continuing with invalid data here.
Fixes 3f0caa3cbf94 ("mt76: mt7915: add support for continuous tx in testmode")Signed-off-by Arnd Bergmann <[email protected]>
Please remove the break and send v2.
Patch set to Changes Requested.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches