netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pds_core: Fix possible double free in error handling path
@ 2024-03-01  2:23 hyper
  2024-03-01 17:55 ` Nelson, Shannon
  0 siblings, 1 reply; 10+ messages in thread
From: hyper @ 2024-03-01  2:23 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, jitxie, huntazhang, hyper

When auxiliary_device_add() returns error and then calls
auxiliary_device_uninit(), Callback function pdsc_auxbus_dev_release
calls kfree(padev) to free memory. We shouldn't call kfree(padev)
again in the error handling path.

Fix this by returning error directly after calling
auxiliary_device_uninit().

Fixes: 4569cce43bc6 ("pds_core: add auxiliary_bus devices")
Signed-off-by: hyper <hyperlyzcs@gmail.com>
---
 drivers/net/ethernet/amd/pds_core/auxbus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/amd/pds_core/auxbus.c b/drivers/net/ethernet/amd/pds_core/auxbus.c
index 11c23a7f3172..d6eedd78d5cc 100644
--- a/drivers/net/ethernet/amd/pds_core/auxbus.c
+++ b/drivers/net/ethernet/amd/pds_core/auxbus.c
@@ -174,6 +174,8 @@ static struct pds_auxiliary_dev *pdsc_auxbus_dev_register(struct pdsc *cf,
 
 err_out_uninit:
 	auxiliary_device_uninit(aux_dev);
+	return ERR_PTR(err);
+
 err_out:
 	kfree(padev);
 	return ERR_PTR(err);
-- 
2.36.1


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

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

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01  2:23 [PATCH] pds_core: Fix possible double free in error handling path hyper
2024-03-01 17:55 ` Nelson, Shannon
2024-03-03  8:49   ` [PATCH net V2] net: " hyper
2024-03-04 17:21     ` Nelson, Shannon
2024-03-04 20:26     ` Breno Leitao
2024-03-05 14:58     ` Paolo Abeni
2024-03-06 10:57       ` [PATCH net V3] " Yongzhi Liu
2024-03-06 13:44         ` Wojciech Drewek
2024-03-06 17:05         ` Nelson, Shannon
2024-03-07 11:10         ` 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).