[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240301022325.20861-1-hyperlyzcs@gmail.com>
Date: Fri, 1 Mar 2024 10:23:25 +0800
From: hyper <hyperlyzcs@...il.com>
To: shannon.nelson@....com,
brett.creeley@....com,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com
Cc: netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
jitxie@...cent.com,
huntazhang@...cent.com,
hyper <hyperlyzcs@...il.com>
Subject: [PATCH] pds_core: Fix possible double free in error handling path
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@...il.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
Powered by blists - more mailing lists