Skip to content

Commit fdfe013

Browse files
Al Virobrauner
authored andcommitted
fix a leak in fcntl_dirnotify()
[into #fixes, unless somebody objects] Lifetime of new_dn_mark is controlled by that of its ->fsn_mark, pointed to by new_fsn_mark. Unfortunately, a failure exit had been inserted between the allocation of new_dn_mark and the call of fsnotify_init_mark(), ending up with a leak. Fixes: 1934b21 "file: reclaim 24 bytes from f_owner" Signed-off-by: Al Viro <[email protected]> Link: https://lore.kernel.org/20250712171843.GB1880847@ZenIV Signed-off-by: Christian Brauner <[email protected]>
1 parent 177bb4c commit fdfe013

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/notify/dnotify/dnotify.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,17 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned int arg)
308308
goto out_err;
309309
}
310310

311+
error = file_f_owner_allocate(filp);
312+
if (error)
313+
goto out_err;
314+
311315
/* new fsnotify mark, we expect most fcntl calls to add a new mark */
312316
new_dn_mark = kmem_cache_alloc(dnotify_mark_cache, GFP_KERNEL);
313317
if (!new_dn_mark) {
314318
error = -ENOMEM;
315319
goto out_err;
316320
}
317321

318-
error = file_f_owner_allocate(filp);
319-
if (error)
320-
goto out_err;
321-
322322
/* set up the new_fsn_mark and new_dn_mark */
323323
new_fsn_mark = &new_dn_mark->fsn_mark;
324324
fsnotify_init_mark(new_fsn_mark, dnotify_group);

0 commit comments

Comments
 (0)