mirror of
https://github.com/sysprog21/lkmpg.git
synced 2024-11-22 05:50:41 +08:00
Fix potential memory leak in vinput
In the export_store function, the error handling paths followed a successful vinput_alloc_vdevice call are missing a corresponding input_free_device call. Since vinput_alloc_vdevice internally calls input_allocate_device, and input_register_device has not been called yet, input_free_device should be used to properly free the allocated input_device struct in this scenario[1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/input/input.c#n2094
This commit is contained in:
parent
67713859df
commit
b482911efb
|
@ -283,10 +283,12 @@ static ssize_t export_store(struct class *class, struct class_attribute *attr,
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
fail_register_vinput:
|
fail_register_vinput:
|
||||||
|
input_free_device(vinput->input);
|
||||||
device_unregister(&vinput->dev);
|
device_unregister(&vinput->dev);
|
||||||
/* avoid calling vinput_destroy_vdevice() twice */
|
/* avoid calling vinput_destroy_vdevice() twice */
|
||||||
return err;
|
return err;
|
||||||
fail_register:
|
fail_register:
|
||||||
|
input_free_device(vinput->input);
|
||||||
vinput_destroy_vdevice(vinput);
|
vinput_destroy_vdevice(vinput);
|
||||||
fail:
|
fail:
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user