This is a note to let you know that I've just added the patch titled file: Merge __alloc_fd into alloc_fd to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: file-merge-__alloc_fd-into-alloc_fd.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 8e0a0480ded04b7da413b74db4e0bd621e7aa916 Author: Eric W. Biederman <ebiederm@xxxxxxxxxxxx> Date: Fri Nov 20 17:14:37 2020 -0600 file: Merge __alloc_fd into alloc_fd [ Upstream commit aa384d10f3d06d4b85597ff5df41551262220e16 ] The function __alloc_fd was added to support binder[1]. With binder fixed[2] there are no more users. As alloc_fd just calls __alloc_fd with "files=current->files", merge them together by transforming the files parameter into a local variable initialized to current->files. [1] dcfadfa4ec5a ("new helper: __alloc_fd()") [2] 44d8047f1d87 ("binder: use standard functions to allocate fds") Acked-by: Christian Brauner <christian.brauner@xxxxxxxxxx> v1: https://lkml.kernel.org/r/20200817220425.9389-16-ebiederm@xxxxxxxxxxxx Link: https://lkml.kernel.org/r/20201120231441.29911-20-ebiederm@xxxxxxxxxxxx Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxx> Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/file.c b/fs/file.c index 9e2b171b92520..48d0306e42ccc 100644 --- a/fs/file.c +++ b/fs/file.c @@ -509,9 +509,9 @@ static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start) /* * allocate a file descriptor, mark it busy. */ -int __alloc_fd(struct files_struct *files, - unsigned start, unsigned end, unsigned flags) +static int alloc_fd(unsigned start, unsigned end, unsigned flags) { + struct files_struct *files = current->files; unsigned int fd; int error; struct fdtable *fdt; @@ -567,14 +567,9 @@ int __alloc_fd(struct files_struct *files, return error; } -static int alloc_fd(unsigned start, unsigned end, unsigned flags) -{ - return __alloc_fd(current->files, start, end, flags); -} - int __get_unused_fd_flags(unsigned flags, unsigned long nofile) { - return __alloc_fd(current->files, 0, nofile, flags); + return alloc_fd(0, nofile, flags); } int get_unused_fd_flags(unsigned flags) diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index 6e8743a4c9d31..d26b884fcc5cc 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -124,8 +124,6 @@ int iterate_fd(struct files_struct *, unsigned, int (*)(const void *, struct file *, unsigned), const void *); -extern int __alloc_fd(struct files_struct *files, - unsigned start, unsigned end, unsigned flags); extern int __close_fd(struct files_struct *files, unsigned int fd); extern int __close_range(unsigned int fd, unsigned int max_fd, unsigned int flags);