]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
reset: gpio: fix double free in reset_add_gpio_aux_device() error path
authorGuangshuo Li <lgs201920130244@gmail.com>
Sat, 21 Mar 2026 07:42:40 +0000 (15:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Apr 2026 12:29:52 +0000 (14:29 +0200)
commit fbffb8c7c7bb4d38e9f65e0bee446685011de5d8 upstream.

When __auxiliary_device_add() fails, reset_add_gpio_aux_device()
calls auxiliary_device_uninit(adev).

The device release callback reset_gpio_aux_device_release() frees
adev, but the current error path then calls kfree(adev) again,
causing a double free.

Keep kfree(adev) for the auxiliary_device_init() failure path, but
avoid freeing adev after auxiliary_device_uninit().

Fixes: 5fc4e4cf7a22 ("reset: gpio: use software nodes to setup the GPIO lookup")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/reset/core.c

index 0135dd0ae20498396fdb5a682f913b6048cb5750..58ecde760b6ef0af0a4a52a9887025ced2f289d1 100644 (file)
@@ -856,7 +856,6 @@ static int reset_add_gpio_aux_device(struct device *parent,
        ret = __auxiliary_device_add(adev, "reset");
        if (ret) {
                auxiliary_device_uninit(adev);
-               kfree(adev);
                return ret;
        }