Skip to content

Commit 40a1926

Browse files
author
Al Viro
committed
fix the breakage in close_fd_get_file() calling conventions change
It used to grab an extra reference to struct file rather than just transferring to caller the one it had removed from descriptor table. New variant doesn't, and callers need to be adjusted. Reported-and-tested-by: [email protected] Fixes: 6319194 ("Unify the primitives for file descriptor closing") Signed-off-by: Al Viro <[email protected]>
1 parent 6319194 commit 40a1926

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
@@ -1857,6 +1857,8 @@ static void binder_deferred_fd_close(int fd)
18571857
init_task_work(&twcb->twork, binder_do_fd_close);
18581858
twcb->file = close_fd_get_file(fd);
18591859
if (twcb->file) {
1860+
// pin it until binder_do_fd_close(); see comments there
1861+
get_file(twcb->file);
18601862
filp_close(twcb->file, current->files);
18611863
task_work_add(current, &twcb->twork, TWA_RESUME);
18621864
} 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
@@ -5110,7 +5110,7 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags)
51105110
struct files_struct *files = current->files;
51115111
struct io_close *close = &req->close;
51125112
struct fdtable *fdt;
5113-
struct file *file = NULL;
5113+
struct file *file;
51145114
int ret = -EBADF;
51155115

51165116
if (req->close.file_slot) {
@@ -5127,7 +5127,6 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags)
51275127
file = fdt->fd[close->fd];
51285128
if (!file || file->f_op == &io_uring_fops) {
51295129
spin_unlock(&files->file_lock);
5130-
file = NULL;
51315130
goto err;
51325131
}
51335132

@@ -5147,8 +5146,6 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags)
51475146
err:
51485147
if (ret < 0)
51495148
req_set_fail(req);
5150-
if (file)
5151-
fput(file);
51525149
__io_req_complete(req, issue_flags, ret, 0);
51535150
return 0;
51545151
}

0 commit comments

Comments
 (0)