netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue()
@ 2024-07-17  8:47 Lorenzo Bianconi
  2024-07-17 10:40 ` Simon Horman
  2024-07-18 11:11 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2024-07-17  8:47 UTC (permalink / raw)
  To: netdev
  Cc: nbd, sean.wang, Mark-MC.Lee, davem, edumazet, kuba, pabeni,
	linux-arm-kernel, linux-mediatek, angelogioacchino.delregno,
	lorenzo.bianconi83

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(-)

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--;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue()
  2024-07-17  8:47 [PATCH net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue() Lorenzo Bianconi
@ 2024-07-17 10:40 ` Simon Horman
  2024-07-18 11:11 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-07-17 10:40 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: netdev, nbd, sean.wang, Mark-MC.Lee, davem, edumazet, kuba,
	pabeni, linux-arm-kernel, linux-mediatek,
	angelogioacchino.delregno, lorenzo.bianconi83

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>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue()
  2024-07-17  8:47 [PATCH net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue() Lorenzo Bianconi
  2024-07-17 10:40 ` Simon Horman
@ 2024-07-18 11:11 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-07-18 11:11 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: netdev, nbd, sean.wang, Mark-MC.Lee, davem, edumazet, kuba,
	pabeni, linux-arm-kernel, linux-mediatek,
	angelogioacchino.delregno, lorenzo.bianconi83

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-18 11:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-17  8:47 [PATCH net] net: airoha: Fix NULL pointer dereference in airoha_qdma_cleanup_rx_queue() Lorenzo Bianconi
2024-07-17 10:40 ` Simon Horman
2024-07-18 11:11 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).