]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: mana: Fix possible double free in error handling path
authorMa Ke <make24@iscas.ac.cn>
Tue, 25 Jun 2024 13:03:14 +0000 (21:03 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jul 2024 07:37:56 +0000 (09:37 +0200)
[ Upstream commit 1864b8224195d0e43ddb92a8151f54f6562090cc ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/microsoft/mana/mana_en.c

index d8af5e7e15b4d82ebf20c610cea7ab2ec19625a8..191d50ba646d8f44743d10fee49aa9cdbd1ed47f 100644 (file)
@@ -2800,6 +2800,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;