ath10k: fix invalid dma_addr_t token assignment
Subsystems (3)
PATCH 1/1 ath10k: fix invalid dma_addr_t token assignment
From: Arnd Bergmann <[email protected]>
Using a kernel pointer in place of a dma_addr_t token can lead to undefined behavior if that makes it into cache management functions. The compiler caught one such attempt in a cast:
drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_add_interface':drivers/net/wireless/ath/ath10k/mac.c:5586:47: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
5586 | arvif->beacon_paddr = (dma_addr_t)arvif->beacon_buf;
| ^
Looking through how this gets used down the way, I'm fairly sure that beacon_paddr is never accessed again for ATH10K_DEV_TYPE_HL devices, and if it was accessed, that would be a bug.
Change the assignment to use a known-invalid address token instead, which avoids the warning and makes it easier to catch bugs if it does end up getting used.
--- drivers/net/wireless/ath/ath10k/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/mac.c +1 -1
@@ -5583,7 +5583,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,if (ar->bus_param.dev_type ==ATH10K_DEV_TYPE_HL ) { arvif->beacon_buf =kmalloc (IEEE80211_MAX_FRAME_LEN ,GFP_KERNEL ); - arvif->beacon_paddr = (dma_addr_t )arvif->beacon_buf; + arvif->beacon_paddr =DMA_MAPPING_ERROR ; }else { arvif->beacon_buf = dma_alloc_coherent(ar->dev,
Signature · 1 line
2.29.2
Quoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Using a kernel pointer in place of a
dma_addr_ttoken can lead to undefined behavior if that makes it into cache management functions. The compiler caught one such attempt in a cast:
Quoted 8 lines
drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_add_interface':drivers/net/wireless/ath/ath10k/mac.c:5586:47: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
5586 |arvif->beacon_paddr= (dma_addr_t)arvif->beacon_buf;
| ^Looking through how this gets used down the way, I'm fairly sure that
beacon_paddris never accessed again forATH10K_DEV_TYPE_HLdevices, and if it was accessed, that would be a bug.
That's my understanding as well. beacon_paddr is only accessed in ath10k_wmi_event_host_swba() and only low latency (ATH10K_DEV_TYPE_LL) should use that function.
Quoted 15 lines
Change the assignment to use a known-invalid address token instead, which avoids the warning and makes it easier to catch bugs if it does end up getting used.
Fixes e263bdab9c0e ("ath10k: high latency fixes for beacon buffer")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/ath/ath10k/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/ath/ath10k/mac.c +0
-0
drivers/net/wireless/ath/ath10k/mac.c static int ath10k_add_interface(struct ieee80211_hw *hw, · line 5586
Quoted 5 lines
drivers/net/wireless/ath/ath10k/mac.c +1
-1@@ -5583,7 +5583,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,if (ar->bus_param.dev_type ==ATH10K_DEV_TYPE_HL ) { arvif->beacon_buf =kmalloc (IEEE80211_MAX_FRAME_LEN ,GFP_KERNEL ); - arvif->beacon_paddr = (dma_addr_t )arvif->beacon_buf; + arvif->beacon_paddr =DMA_MAPPING_ERROR ;
In the pending branch I added a comment here:
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 18 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Using a kernel pointer in place of a
dma_addr_ttoken can lead to undefined behavior if that makes it into cache management functions. The compiler caught one such attempt in a cast:
drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_add_interface':drivers/net/wireless/ath/ath10k/mac.c:5586:47: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
5586 |arvif->beacon_paddr=
(dma_addr_t)arvif->beacon_buf;
| ^Looking through how this gets used down the way, I'm fairly sure that
beacon_paddris never accessed again forATH10K_DEV_TYPE_HLdevices, and if it was accessed, that would be a bug.
Quoted 6 lines
Change the assignment to use a known-invalid address token instead, which avoids the warning and makes it easier to catch bugs if it does end up getting used.
Fixes e263bdab9c0e ("ath10k: high latency fixes for beacon buffer")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 14 lines · Arnd Bergmann
Using a kernel pointer in place of a
dma_addr_ttoken can lead to undefined behavior if that makes it into cache management functions. The compiler caught one such attempt in a cast:
drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_add_interface':drivers/net/wireless/ath/ath10k/mac.c:5586:47: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
5586 |arvif->beacon_paddr= (dma_addr_t)arvif->beacon_buf;
| ^Looking through how this gets used down the way, I'm fairly sure that
beacon_paddris never accessed again forATH10K_DEV_TYPE_HLdevices, and if it was accessed, that would be a bug.
Quoted 7 lines
Change the assignment to use a known-invalid address token instead, which avoids the warning and makes it easier to catch bugs if it does end up getting used.
Fixes e263bdab9c0e ("ath10k: high latency fixes for beacon buffer")Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
937e79c67740 ath10k: fix invalid dma_addr_t token assignment
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches