Skip to content

Commit 5fd77cc

Browse files
Jiawen Wukuba-moo
authored andcommitted
net: libwx: fix the using of Rx buffer DMA
The wx_rx_buffer structure contained two DMA address fields: 'dma' and 'page_dma'. However, only 'page_dma' was actually initialized and used to program the Rx descriptor. But 'dma' was uninitialized and used in some paths. This could lead to undefined behavior, including DMA errors or use-after-free, if the uninitialized 'dma' was used. Althrough such error has not yet occurred, it is worth fixing in the code. Fixes: 3c47e8a ("net: libwx: Support to receive packets in NAPI") Cc: [email protected] Signed-off-by: Jiawen Wu <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1b7e585 commit 5fd77cc

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

drivers/net/ethernet/wangxun/libwx/wx_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static bool wx_alloc_mapped_page(struct wx_ring *rx_ring,
307307
return false;
308308
dma = page_pool_get_dma_addr(page);
309309

310-
bi->page_dma = dma;
310+
bi->dma = dma;
311311
bi->page = page;
312312
bi->page_offset = 0;
313313

@@ -344,7 +344,7 @@ void wx_alloc_rx_buffers(struct wx_ring *rx_ring, u16 cleaned_count)
344344
DMA_FROM_DEVICE);
345345

346346
rx_desc->read.pkt_addr =
347-
cpu_to_le64(bi->page_dma + bi->page_offset);
347+
cpu_to_le64(bi->dma + bi->page_offset);
348348

349349
rx_desc++;
350350
bi++;

drivers/net/ethernet/wangxun/libwx/wx_type.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,6 @@ struct wx_tx_buffer {
997997
struct wx_rx_buffer {
998998
struct sk_buff *skb;
999999
dma_addr_t dma;
1000-
dma_addr_t page_dma;
10011000
struct page *page;
10021001
unsigned int page_offset;
10031002
};

0 commit comments

Comments
 (0)