[PATCH 35/44] 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)
committerSalvatore Bonaccorso <carnil@debian.org>
Sat, 2 Aug 2025 13:13:02 +0000 (15:13 +0200)
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>
(cherry picked from commit 1864b8224195d0e43ddb92a8151f54f6562090cc)
Signed-off-by: Bastian Blank <waldi@debian.org>
Gbp-Pq: Topic features/all/ethernet-microsoft
Gbp-Pq: Name 0035-net-mana-Fix-possible-double-free-in-error-handling-.patch

drivers/net/ethernet/microsoft/mana/mana_en.c

index 65d877d2ebf3d8a66faeed32ba4ba8c84461ba7d..e2a1767e1cb845327cd64e928ffdc90074ea42cf 100644 (file)
@@ -2668,6 +2668,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;