Skip to contentSkip to conversation

bnge: return after auxiliary_device_uninit() in error path

PATCH Applied Greg Kroah-Hartman 3 participants 3 messages Apr 11 – Apr 13

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bnge: return after auxiliary_device_uninit() in error path

When auxiliary_device_add() fails, the error block calls auxiliary_device_uninit() but does not return. The uninit drops the last reference and synchronously runs bnge_aux_dev_release(), which sets bd->auxr_dev = NULL and frees the underlying object. The subsequent bd->auxr_dev->net = bd->netdev then dereferences NULL, which is not a good thing to have happen when trying to clean up from an error.

Add the missing return, as the auxiliary bus documentation states is a requirement (seems that LLM tools read documentation better than humans do...)

Cc Vikas Gupta <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Fixes 8ac050ec3b1c ("bng_en: Add RoCE aux device support")
Cc stable <[email protected]>
Assisted-by gregkh_clanker_t1000
---
 drivers/net/ethernet/broadcom/bnge/bnge_auxr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnge/bnge_auxr.c +1 -0
index b942076762ef..67e93e17d4d9 100644
@@ -194,6 +194,7 @@ void bnge_rdma_aux_device_add(struct bnge_dev *bd)
 		dev_warn(bd->dev, "Failed to add auxiliary device for ROCE\n");
 		auxiliary_device_uninit(aux_dev);
 		bd->flags &= ~BNGE_EN_ROCE;
+		return;
 	}
 
 	bd->auxr_dev->net = bd->netdev;
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Greg Kroah-Hartman

When auxiliary_device_add() fails, the error block calls auxiliary_device_uninit() but does not return. The uninit drops the last reference and synchronously runs bnge_aux_dev_release(), which sets bd->auxr_dev = NULL and frees the underlying object. The subsequent bd->auxr_dev->net = bd->netdev then dereferences NULL, which is not a good thing to have happen when trying to clean up from an error.

Add the missing return, as the auxiliary bus documentation states is a requirement (seems that LLM tools read documentation better than humans do...)

Quoted 10 lines
Cc Vikas Gupta <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Fixes 8ac050ec3b1c ("bng_en: Add RoCE aux device support")
Cc stable <[email protected]>
Assisted-by gregkh_clanker_t1000
Quoted 19 lines
---
 drivers/net/ethernet/broadcom/bnge/bnge_auxr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnge/bnge_auxr.c +1 -1
index b942076762ef..67e93e17d4d9 100644
@@ -194,6 +194,7 @@ void bnge_rdma_aux_device_add(struct bnge_dev *bd)
                dev_warn(bd->dev, "Failed to add auxiliary device for ROCE\n");
                auxiliary_device_uninit(aux_dev);
                bd->flags &= ~BNGE_EN_ROCE;
+               return;
        }
 
        bd->auxr_dev->net = bd->netdev;
--

2.53.0

#2 lore raw
In reply to Greg Kroah-Hartman
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Sat, 11 Apr 2026 12:45:25 +0200 you wrote:

When auxiliary_device_add() fails, the error block calls auxiliary_device_uninit() but does not return. The uninit drops the last reference and synchronously runs bnge_aux_dev_release(), which sets bd->auxr_dev = NULL and frees the underlying object. The subsequent bd->auxr_dev->net = bd->netdev then dereferences NULL, which is not a good thing to have happen when trying to clean up from an error.

[...]

Here is the summary with links:
- [net] bnge: return after auxiliary_device_uninit() in error path

    https://git.kernel.org/netdev/net/c/8b0c25528cb6

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html