Commit 4e076ff6 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Paolo Abeni

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: 23020f04 ("net: airoha: Introduce ethernet support for EN7581 SoC")
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/7330a41bba720c33abc039955f6172457a3a34f0.1721205981.git.lorenzo@kernel.orgSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent a1a30537
...@@ -1585,7 +1585,6 @@ static int airoha_qdma_init_rx_queue(struct airoha_eth *eth, ...@@ -1585,7 +1585,6 @@ static int airoha_qdma_init_rx_queue(struct airoha_eth *eth,
static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q) static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q)
{ {
enum dma_data_direction dir = page_pool_get_dma_dir(q->page_pool);
struct airoha_eth *eth = q->eth; struct airoha_eth *eth = q->eth;
while (q->queued) { while (q->queued) {
...@@ -1593,7 +1592,7 @@ static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q) ...@@ -1593,7 +1592,7 @@ static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q)
struct page *page = virt_to_head_page(e->buf); struct page *page = virt_to_head_page(e->buf);
dma_sync_single_for_cpu(eth->dev, e->dma_addr, e->dma_len, dma_sync_single_for_cpu(eth->dev, e->dma_addr, e->dma_len,
dir); page_pool_get_dma_dir(q->page_pool));
page_pool_put_full_page(q->page_pool, page, false); page_pool_put_full_page(q->page_pool, page, false);
q->tail = (q->tail + 1) % q->ndesc; q->tail = (q->tail + 1) % q->ndesc;
q->queued--; q->queued--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment