Skip to content

Commit 3ec01e2

Browse files
committed
Fix potential reference count leak in vinput
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.
1 parent ac18946 commit 3ec01e2

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
@@ -284,6 +284,8 @@ static ssize_t export_store(struct class *class, struct class_attribute *attr,
284284

285285
fail_register_vinput:
286286
device_unregister(&vinput->dev);
287+
/* avoid calling vinput_destroy_vdevice() twice */
288+
return err;
287289
fail_register:
288290
vinput_destroy_vdevice(vinput);
289291
fail:

0 commit comments

Comments
 (0)