diff mbox series

stm class: Fix a potential double free in stm_register_device

Message ID 20230921050353.23485-1-dinghao.liu@zju.edu.cn (mailing list archive)
State New, archived
Headers show
Series stm class: Fix a potential double free in stm_register_device | expand

Commit Message

Dinghao Liu Sept. 21, 2023, 5:03 a.m. UTC
In the error handling path after err_device, the vfree is
redundant. stm_device_release will free the stm device
after put_device(). Set stm to NULL to prevent double free.

Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/hwtracing/stm/core.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 534fbefc7f6a..5500aa5046ee 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -915,6 +915,7 @@  int stm_register_device(struct device *parent, struct stm_data *stm_data,
 
 	/* matches device_initialize() above */
 	put_device(&stm->dev);
+	stm = NULL;
 err_free:
 	vfree(stm);