Commit 0e7d523
ntsync: fix a file reference leak in drivers/misc/ntsync.c
struct ntsync_obj contains a reference to struct file
and that reference contributes to refcount - ntsync_alloc_obj()
grabs it. Normally the object is destroyed (and reference
to obj->file dropped) in ntsync_obj_release(). However, in
case of ntsync_obj_get_fd() failure the object is destroyed
directly by its creator.
That case should also drop obj->file; plain kfree(obj)
is not enough there - it ends up leaking struct file * reference.
Take that logics into a helper (ntsync_free_obj()) and
use it in both codepaths that destroy ntsync_obj instances.
Fixes: b46271e "ntsync: Introduce NTSYNC_IOC_CREATE_SEM"
Signed-off-by: Al Viro <[email protected]>
Reviewed-by: Elizabeth Figura <[email protected]>
Link: https://lore.kernel.org/r/20250115025002.GA1977892@ZenIV
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 2217573 commit 0e7d523
1 file changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
654 | | - | |
| 654 | + | |
655 | 655 | | |
656 | | - | |
657 | | - | |
658 | 656 | | |
659 | 657 | | |
| 658 | + | |
660 | 659 | | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
661 | 663 | | |
662 | 664 | | |
663 | 665 | | |
| |||
755 | 757 | | |
756 | 758 | | |
757 | 759 | | |
758 | | - | |
| 760 | + | |
759 | 761 | | |
760 | 762 | | |
761 | 763 | | |
| |||
0 commit comments