summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMa Ke <make24@iscas.ac.cn>2024-06-25 16:03:14 +0300
committerPaolo Abeni <pabeni@redhat.com>2024-06-27 13:35:58 +0300
commit1864b8224195d0e43ddb92a8151f54f6562090cc (patch)
treea3354945c7344a4756deaf1e4f8e13c6ebc83b6c /drivers
parent3f4d9e4f825c617c711f5e1da3059238722f08c1 (diff)
downloadlinux-1864b8224195d0e43ddb92a8151f54f6562090cc.tar.xz
net: mana: Fix possible double free in error handling path
When auxiliary_device_add() returns error and then calls auxiliary_device_uninit(), callback function adev_release calls kfree(madev). We shouldn't call kfree(madev) again in the error handling path. Set 'madev' to NULL. Fixes: a69839d4327d ("net: mana: Add support for auxiliary device") Signed-off-by: Ma Ke <make24@iscas.ac.cn> Link: https://patch.msgid.link/20240625130314.2661257-1-make24@iscas.ac.cn Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/microsoft/mana/mana_en.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index d087cf954f75..608ad31a9702 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -2798,6 +2798,8 @@ static int add_adev(struct gdma_dev *gd)
if (ret)
goto init_fail;
+ /* madev is owned by the auxiliary device */
+ madev = NULL;
ret = auxiliary_device_add(adev);
if (ret)
goto add_fail;