diff mbox series

[net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue()

Message ID 7330a41bba720c33abc039955f6172457a3a34f0.1721205981.git.lorenzo@kernel.org (mailing list archive)
State Accepted
Commit 4e076ff6ad5302c015617da30d877b4cdcbdf613
Delegated to: Netdev Maintainers
Headers show
Series [net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 661 this patch: 661
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: matthias.bgg@gmail.com
netdev/build_clang success Errors and warnings before: 662 this patch: 662
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 662 this patch: 662
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-07-17--15-00 (tests: 699)

Commit Message

Lorenzo Bianconi July 17, 2024, 8:47 a.m. UTC
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: 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/mediatek/airoha_eth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Simon Horman July 17, 2024, 10:40 a.m. UTC | #1
On Wed, Jul 17, 2024 at 10:47:19AM +0200, Lorenzo Bianconi wrote:
> 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: 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Reviewed-by: Simon Horman <horms@kernel.org>
patchwork-bot+netdevbpf@kernel.org July 18, 2024, 11:11 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Wed, 17 Jul 2024 10:47:19 +0200 you wrote:
> 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: 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> [...]

Here is the summary with links:
  - [net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue()
    https://git.kernel.org/netdev/net/c/4e076ff6ad53

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c
index cc1a69522f61..16761fde6c6c 100644
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
@@ -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)
 {
-	enum dma_data_direction dir = page_pool_get_dma_dir(q->page_pool);
 	struct airoha_eth *eth = q->eth;
 
 	while (q->queued) {
@@ -1593,7 +1592,7 @@  static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q)
 		struct page *page = virt_to_head_page(e->buf);
 
 		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);
 		q->tail = (q->tail + 1) % q->ndesc;
 		q->queued--;