Skip to content

Commit

Permalink
Fix potential reference count leak in vinput
Browse files Browse the repository at this point in the history
In the export_store function, when vinput_register_vdevice fails, the
current error handling process calls device_unregister followed by
vinput_destroy_vdevice. However, the device_unregister here triggers its
release function, which already includes a call to
vinput_destroy_vdevice. As a result, vinput_destroy_vdevice is called
twice. Since vinput_destroy_vdevice contains module_put, this double
call must be avoided to prevent potential reference count issues.
  • Loading branch information
NOVBobLee committed Oct 24, 2024
1 parent ac18946 commit 3ec01e2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/vinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ static ssize_t export_store(struct class *class, struct class_attribute *attr,

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

0 comments on commit 3ec01e2

Please sign in to comment.