diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-02-09 16:58:28 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-02-09 16:58:28 -0800 |
| commit | 26c9342bb761e463774a64fb6210b4f95f5bc035 (patch) | |
| tree | 486d504cf5dcfe041eba4d9d5eb468a5a7b81566 /mm | |
| parent | 8a5203c630c67d578975ff237413f5e0b5000af8 (diff) | |
| parent | 0787a93baa1aab9fd0cb8500105d11d3d3a58f7a (diff) | |
Merge tag 'pull-filename' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs 'struct filename' updates from Al Viro:
"[Mostly] sanitize struct filename handling"
* tag 'pull-filename' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (68 commits)
sysfs(2): fs_index() argument is _not_ a pathname
alpha: switch osf_mount() to strndup_user()
ksmbd: use CLASS(filename_kernel)
mqueue: switch to CLASS(filename)
user_statfs(): switch to CLASS(filename)
statx: switch to CLASS(filename_maybe_null)
quotactl_block(): switch to CLASS(filename)
chroot(2): switch to CLASS(filename)
move_mount(2): switch to CLASS(filename_maybe_null)
namei.c: switch user pathname imports to CLASS(filename{,_flags})
namei.c: convert getname_kernel() callers to CLASS(filename_kernel)
do_f{chmod,chown,access}at(): use CLASS(filename_uflags)
do_readlinkat(): switch to CLASS(filename_flags)
do_sys_truncate(): switch to CLASS(filename)
do_utimes_path(): switch to CLASS(filename_uflags)
chdir(2): unspaghettify a bit...
do_fchownat(): unspaghettify a bit...
fspick(2): use CLASS(filename_flags)
name_to_handle_at(): use CLASS(filename_uflags)
vfs_open_tree(): use CLASS(filename_uflags)
...
Diffstat (limited to 'mm')
| -rw-r--r-- | mm/huge_memory.c | 15 | ||||
| -rw-r--r-- | mm/swapfile.c | 21 |
2 files changed, 6 insertions, 30 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 40cf59301c21..a6d37902b73d 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -4692,23 +4692,18 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start, pgoff_t off_end, unsigned int new_order, long in_folio_offset) { - struct filename *file; struct file *candidate; struct address_space *mapping; - int ret = -EINVAL; pgoff_t index; int nr_pages = 1; unsigned long total = 0, split = 0; unsigned int min_order; unsigned int target_order; - file = getname_kernel(file_path); - if (IS_ERR(file)) - return ret; - + CLASS(filename_kernel, file)(file_path); candidate = file_open_name(file, O_RDONLY, 0); if (IS_ERR(candidate)) - goto out; + return -EINVAL; pr_debug("split file-backed THPs in file: %s, page offset: [0x%lx - 0x%lx], new_order: %u, in_folio_offset: %ld\n", file_path, off_start, off_end, new_order, in_folio_offset); @@ -4757,12 +4752,8 @@ next: } filp_close(candidate, NULL); - ret = 0; - pr_debug("%lu of %lu file-backed THP split\n", split, total); -out: - putname(file); - return ret; + return 0; } #define MAX_INPUT_BUF_SZ 255 diff --git a/mm/swapfile.c b/mm/swapfile.c index 46d2008e4b99..25120cf7c480 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2831,7 +2831,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) struct file *swap_file, *victim; struct address_space *mapping; struct inode *inode; - struct filename *pathname; unsigned int maxpages; int err, found = 0; @@ -2840,14 +2839,10 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) BUG_ON(!current->mm); - pathname = getname(specialfile); - if (IS_ERR(pathname)) - return PTR_ERR(pathname); - + CLASS(filename, pathname)(specialfile); victim = file_open_name(pathname, O_RDWR|O_LARGEFILE, 0); - err = PTR_ERR(victim); if (IS_ERR(victim)) - goto out; + return PTR_ERR(victim); mapping = victim->f_mapping; spin_lock(&swap_lock); @@ -2964,8 +2959,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) out_dput: filp_close(victim, NULL); -out: - putname(pathname); return err; } @@ -3392,7 +3385,6 @@ err: SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) { struct swap_info_struct *si; - struct filename *name; struct file *swap_file = NULL; struct address_space *mapping; struct dentry *dentry; @@ -3422,12 +3414,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) INIT_WORK(&si->discard_work, swap_discard_work); INIT_WORK(&si->reclaim_work, swap_reclaim_work); - name = getname(specialfile); - if (IS_ERR(name)) { - error = PTR_ERR(name); - name = NULL; - goto bad_swap; - } + CLASS(filename, name)(specialfile); swap_file = file_open_name(name, O_RDWR | O_LARGEFILE | O_EXCL, 0); if (IS_ERR(swap_file)) { error = PTR_ERR(swap_file); @@ -3635,8 +3622,6 @@ bad_swap: out: if (!IS_ERR_OR_NULL(folio)) folio_release_kmap(folio, swap_header); - if (name) - putname(name); if (inode) inode_unlock(inode); return error; |
