Skip to content

Commit b482911

Browse files
committed
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
1 parent 6771385 commit b482911

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

examples/vinput.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,12 @@ static ssize_t export_store(struct class *class, struct class_attribute *attr,
283283
return len;
284284

285285
fail_register_vinput:
286+
input_free_device(vinput->input);
286287
device_unregister(&vinput->dev);
287288
/* avoid calling vinput_destroy_vdevice() twice */
288289
return err;
289290
fail_register:
291+
input_free_device(vinput->input);
290292
vinput_destroy_vdevice(vinput);
291293
fail:
292294
return err;

0 commit comments

Comments
 (0)