Skip to content

Commit 4e076ff

Browse files
LorenzoBianconiPaolo Abeni
authored andcommitted
net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue()
Move page_pool_get_dma_dir() inside the while loop of airoha_qdma_cleanup_rx_queue routine in order to avoid possible NULL pointer dereference if airoha_qdma_init_rx_queue() fails before properly allocating the page_pool pointer. Fixes: 23020f0 ("net: airoha: Introduce ethernet support for EN7581 SoC") Signed-off-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/7330a41bba720c33abc039955f6172457a3a34f0.1721205981.git.lorenzo@kernel.org Signed-off-by: Paolo Abeni <[email protected]>
1 parent a1a3053 commit 4e076ff

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/net/ethernet/mediatek/airoha_eth.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,15 +1585,14 @@ static int airoha_qdma_init_rx_queue(struct airoha_eth *eth,
15851585

15861586
static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q)
15871587
{
1588-
enum dma_data_direction dir = page_pool_get_dma_dir(q->page_pool);
15891588
struct airoha_eth *eth = q->eth;
15901589

15911590
while (q->queued) {
15921591
struct airoha_queue_entry *e = &q->entry[q->tail];
15931592
struct page *page = virt_to_head_page(e->buf);
15941593

15951594
dma_sync_single_for_cpu(eth->dev, e->dma_addr, e->dma_len,
1596-
dir);
1595+
page_pool_get_dma_dir(q->page_pool));
15971596
page_pool_put_full_page(q->page_pool, page, false);
15981597
q->tail = (q->tail + 1) % q->ndesc;
15991598
q->queued--;

0 commit comments

Comments
 (0)