stm class: Fix a double vfree in stm_register_device()
Subsystems (3)
PATCH 1/1 stm class: Fix a double vfree in stm_register_device()
While testing stm, stm_register_device() caused a vfree issue:
-----
Trying to vfree() nonexistent vm area (00000000ad30ebb6)
Call Trace: __vfree+0x41/0xe0 vfree+0x5f/0xa0 stm_register_device+0x4b1/0x660 [stm_core] dummy_stm_init+0x248/0x360 [dummy_stm] do_one_initcall+0x149/0x7e0 do_init_module+0x1ef/0x700 load_module+0x3467/0x4140 __do_sys_finit_module+0x10d/0x1a0 do_syscall_64+0x34/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x468ded
-----
This is because put_device(&stm->dev) calls stm_device_release, which would call vfree(stm) inside, so there's no need to do vfree again.
Fix this problem by simply return err after put_device().
Fixes b5e2ced9bf81 ("stm class: Use vmalloc for the master map")
Reported-by Hulk Robot <[email protected]>
Signed-off-by Qinglang Miao <[email protected]>
--- drivers/hwtracing/stm/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwtracing/stm/core.c +2 -0
@@ -915,6 +915,8 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,/* matches device_initialize() above */ put_device (&stm->dev); + +return err; err_free:vfree (stm);
Signature · 1 line
2.23.0