Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/vinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,12 @@ static ssize_t export_store(struct class *class, struct class_attribute *attr,
return len;

fail_register_vinput:
input_free_device(vinput->input);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we call input_allocate_device in vinput_alloc_vdevice , why do we handle it manually instead of putting input_free_device in the corresponding release function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe input_free_device should be decoupled from the release function vinput_destroy_vdevice. In both unexport_store and vinput_unregister, the vinput_unregister_vdevice function is called before device_unregister, with each invoking input_unregister_device followed by vinput_destroy_vdevice. Embedding input_free_device within vinput_destroy_vdevice could contradict the documented comments in the source code [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/input/input.c#n2386

device_unregister(&vinput->dev);
/* avoid calling vinput_destroy_vdevice() twice */
return err;
fail_register:
input_free_device(vinput->input);
vinput_destroy_vdevice(vinput);
fail:
return err;
Expand Down