Commit fbffb8c7 authored by Guangshuo Li's avatar Guangshuo Li Committed by Philipp Zabel
Browse files

reset: gpio: fix double free in reset_add_gpio_aux_device() error path



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: 5fc4e4cf ("reset: gpio: use software nodes to setup the GPIO lookup")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarGuangshuo Li <lgs201920130244@gmail.com>
Reviewed-by: default avatarBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent c961cc86
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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;
	}