Skip to content

Commit 188bf40

Browse files
arndbgregkh
authored andcommitted
ath10k: fix invalid dma_addr_t token assignment
commit 937e79c upstream. 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. Fixes: e263bda ("ath10k: high latency fixes for beacon buffer") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20211014075153.3655910-1-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d41f4d4 commit 188bf40

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • drivers/net/wireless/ath/ath10k

drivers/net/wireless/ath/ath10k/mac.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5473,7 +5473,15 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
54735473
if (ar->bus_param.dev_type == ATH10K_DEV_TYPE_HL) {
54745474
arvif->beacon_buf = kmalloc(IEEE80211_MAX_FRAME_LEN,
54755475
GFP_KERNEL);
5476-
arvif->beacon_paddr = (dma_addr_t)arvif->beacon_buf;
5476+
5477+
/* Using a kernel pointer in place of a dma_addr_t
5478+
* token can lead to undefined behavior if that
5479+
* makes it into cache management functions. Use a
5480+
* known-invalid address token instead, which
5481+
* avoids the warning and makes it easier to catch
5482+
* bugs if it does end up getting used.
5483+
*/
5484+
arvif->beacon_paddr = DMA_MAPPING_ERROR;
54775485
} else {
54785486
arvif->beacon_buf =
54795487
dma_alloc_coherent(ar->dev,

0 commit comments

Comments
 (0)