bnge: return after auxiliary_device_uninit() in error path
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...)
--- drivers/net/ethernet/broadcom/bnge/bnge_auxr.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnge/bnge_auxr.c +1 -0
@@ -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
Quoted 12 lines · Greg Kroah-Hartman
When
auxiliary_device_add()fails, the error block callsauxiliary_device_uninit()but does not return. The uninit drops the last reference and synchronously runsbnge_aux_dev_release(), which setsbd->auxr_dev= NULL and frees the underlying object. The subsequentbd->auxr_dev->net=bd->netdevthen 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_t1000Signed-off-by Greg Kroah-Hartman <[email protected]>
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@@ -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
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 callsauxiliary_device_uninit()but does not return. The uninit drops the last reference and synchronously runsbnge_aux_dev_release(), which setsbd->auxr_dev= NULL and frees the underlying object. The subsequentbd->auxr_dev->net=bd->netdevthen 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