提交 7f88d806 编写于 作者: G Geert Uytterhoeven 提交者: Greg Kroah-Hartman

mt76: Fix comparisons with invalid hardware key index

[ Upstream commit 81c8eccc2404d06082025b773f1d90e8c861bc6a ]

With gcc 4.1.2:

    drivers/net/wireless/mediatek/mt76/mt76x0/tx.c: In function ‘mt76x0_tx’:
    drivers/net/wireless/mediatek/mt76/mt76x0/tx.c:169: warning: comparison is always true due to limited range of data type
    drivers/net/wireless/mediatek/mt76/mt76x2_tx_common.c: In function ‘mt76x2_tx’:
    drivers/net/wireless/mediatek/mt76/mt76x2_tx_common.c:35: warning: comparison is always true due to limited range of data type

While assigning -1 to a u8 works fine, comparing with -1 does not work
as expected.

Fix this by comparing with 0xff, like is already done in some other
places.
Signed-off-by: NGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 1f54ec5b
...@@ -166,7 +166,7 @@ void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, ...@@ -166,7 +166,7 @@ void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
if (sta) { if (sta) {
msta = (struct mt76_sta *) sta->drv_priv; msta = (struct mt76_sta *) sta->drv_priv;
wcid = &msta->wcid; wcid = &msta->wcid;
} else if (vif && (!info->control.hw_key && wcid->hw_key_idx != -1)) { } else if (vif && (!info->control.hw_key && wcid->hw_key_idx != 0xff)) {
struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
wcid = &mvif->group_wcid; wcid = &mvif->group_wcid;
......
...@@ -32,7 +32,7 @@ void mt76x2_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, ...@@ -32,7 +32,7 @@ void mt76x2_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
msta = (struct mt76x2_sta *)control->sta->drv_priv; msta = (struct mt76x2_sta *)control->sta->drv_priv;
wcid = &msta->wcid; wcid = &msta->wcid;
/* sw encrypted frames */ /* sw encrypted frames */
if (!info->control.hw_key && wcid->hw_key_idx != -1) if (!info->control.hw_key && wcid->hw_key_idx != 0xff)
control->sta = NULL; control->sta = NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册