Skip to content

Commit 6684cf4

Browse files
committed
Merge tag 'pull-work.fd-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull file descriptor fix from Al Viro: "Fix for breakage in #work.fd this window" * tag 'pull-work.fd-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: fix the breakage in close_fd_get_file() calling conventions change
2 parents 815b196 + 40a1926 commit 6684cf4

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

drivers/android/binder.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,8 @@ static void binder_deferred_fd_close(int fd)
18861886
init_task_work(&twcb->twork, binder_do_fd_close);
18871887
twcb->file = close_fd_get_file(fd);
18881888
if (twcb->file) {
1889+
// pin it until binder_do_fd_close(); see comments there
1890+
get_file(twcb->file);
18891891
filp_close(twcb->file, current->files);
18901892
task_work_add(current, &twcb->twork, TWA_RESUME);
18911893
} else {

fs/file.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,7 @@ struct file *__close_fd_get_file(unsigned int fd)
800800

801801
/*
802802
* variant of close_fd that gets a ref on the file for later fput.
803-
* The caller must ensure that filp_close() called on the file, and then
804-
* an fput().
803+
* The caller must ensure that filp_close() called on the file.
805804
*/
806805
struct file *close_fd_get_file(unsigned int fd)
807806
{

fs/io_uring.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6010,7 +6010,7 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags)
60106010
struct files_struct *files = current->files;
60116011
struct io_close *close = &req->close;
60126012
struct fdtable *fdt;
6013-
struct file *file = NULL;
6013+
struct file *file;
60146014
int ret = -EBADF;
60156015

60166016
if (req->close.file_slot) {
@@ -6029,7 +6029,6 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags)
60296029
lockdep_is_held(&files->file_lock));
60306030
if (!file || file->f_op == &io_uring_fops) {
60316031
spin_unlock(&files->file_lock);
6032-
file = NULL;
60336032
goto err;
60346033
}
60356034

@@ -6049,8 +6048,6 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags)
60496048
err:
60506049
if (ret < 0)
60516050
req_set_fail(req);
6052-
if (file)
6053-
fput(file);
60546051
__io_req_complete(req, issue_flags, ret, 0);
60556052
return 0;
60566053
}

0 commit comments

Comments
 (0)