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: prepare for adding LSM blob to backing_file

In preparation to adding LSM blob to backing_file struct, factor out
helpers init_backing_file() and backing_file_free().

Cc: stable@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-unionfs@vger.kernel.org
Cc: linux-erofs@lists.ozlabs.org
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
[PM: use the term "LSM blob", fix comment style to match file]
Signed-off-by: Paul Moore <paul@paul-moore.com>

authored by

Amir Goldstein and committed by
Paul Moore
880bd496 d1a09195

+20 -2
+20 -2
fs/file_table.c
··· 66 66 } 67 67 EXPORT_SYMBOL_GPL(backing_file_set_user_path); 68 68 69 + static inline void backing_file_free(struct backing_file *ff) 70 + { 71 + path_put(&ff->user_path); 72 + kmem_cache_free(bfilp_cachep, ff); 73 + } 74 + 69 75 static inline void file_free(struct file *f) 70 76 { 71 77 security_file_free(f); ··· 79 73 percpu_counter_dec(&nr_files); 80 74 put_cred(f->f_cred); 81 75 if (unlikely(f->f_mode & FMODE_BACKING)) { 82 - path_put(backing_file_user_path(f)); 83 - kmem_cache_free(bfilp_cachep, backing_file(f)); 76 + backing_file_free(backing_file(f)); 84 77 } else { 85 78 kmem_cache_free(filp_cachep, f); 86 79 } ··· 288 283 return f; 289 284 } 290 285 286 + static int init_backing_file(struct backing_file *ff) 287 + { 288 + memset(&ff->user_path, 0, sizeof(ff->user_path)); 289 + return 0; 290 + } 291 + 291 292 /* 292 293 * Variant of alloc_empty_file() that allocates a backing_file container 293 294 * and doesn't check and modify nr_files. ··· 316 305 return ERR_PTR(error); 317 306 } 318 307 308 + /* The f_mode flags must be set before fput(). */ 319 309 ff->file.f_mode |= FMODE_BACKING | FMODE_NOACCOUNT; 310 + error = init_backing_file(ff); 311 + if (unlikely(error)) { 312 + fput(&ff->file); 313 + return ERR_PTR(error); 314 + } 315 + 320 316 return &ff->file; 321 317 } 322 318 EXPORT_SYMBOL_GPL(alloc_empty_backing_file);