Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: move initializing f_mode before file_ref_init()

The comment above file_ref_init() says:
"We're SLAB_TYPESAFE_BY_RCU so initialize f_ref last."
but file_set_fsnotify_mode() was added after file_ref_init().

Move it right after setting f_mode, where it makes more sense.

Fixes: 711f9b8fbe4f4 ("fsnotify: disable pre-content and permission events by default")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://patch.msgid.link/20260109211536.3565697-1-amir73il@gmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Amir Goldstein and committed by
Christian Brauner
1219e0fe 46329a9d

+5 -5
+5 -5
fs/file_table.c
··· 176 176 177 177 f->f_flags = flags; 178 178 f->f_mode = OPEN_FMODE(flags); 179 + /* 180 + * Disable permission and pre-content events for all files by default. 181 + * They may be enabled later by fsnotify_open_perm_and_set_mode(). 182 + */ 183 + file_set_fsnotify_mode(f, FMODE_NONOTIFY_PERM); 179 184 180 185 f->f_op = NULL; 181 186 f->f_mapping = NULL; ··· 202 197 * refcount bumps we should reinitialize the reused file first. 203 198 */ 204 199 file_ref_init(&f->f_ref, 1); 205 - /* 206 - * Disable permission and pre-content events for all files by default. 207 - * They may be enabled later by fsnotify_open_perm_and_set_mode(). 208 - */ 209 - file_set_fsnotify_mode(f, FMODE_NONOTIFY_PERM); 210 200 return 0; 211 201 } 212 202