Message ID | 20191213183632.19441-7-axboe@kernel.dk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | io_uring items for 5.6 | expand |
On Fri, Dec 13, 2019 at 7:36 PM Jens Axboe <axboe@kernel.dk> wrote: > Just one caller of this, and just use filp_close() there manually. > This is important to allow async close/removal of the fd. [...] > index 3da91a112bab..a250d291c71b 100644 > --- a/fs/file.c > +++ b/fs/file.c > @@ -662,7 +662,7 @@ int __close_fd_get_file(unsigned int fd, struct file **res) > spin_unlock(&files->file_lock); > get_file(file); > *res = file; > - return filp_close(file, files); > + return 0; Above this function is a comment saying "variant of __close_fd that gets a ref on the file for later fput"; that should probably be changed to point out that you also still need to filp_close().
On 12/16/19 12:27 PM, Jann Horn wrote: > On Fri, Dec 13, 2019 at 7:36 PM Jens Axboe <axboe@kernel.dk> wrote: >> Just one caller of this, and just use filp_close() there manually. >> This is important to allow async close/removal of the fd. > [...] >> index 3da91a112bab..a250d291c71b 100644 >> --- a/fs/file.c >> +++ b/fs/file.c >> @@ -662,7 +662,7 @@ int __close_fd_get_file(unsigned int fd, struct file **res) >> spin_unlock(&files->file_lock); >> get_file(file); >> *res = file; >> - return filp_close(file, files); >> + return 0; > > Above this function is a comment saying "variant of __close_fd that > gets a ref on the file for later fput"; that should probably be > changed to point out that you also still need to filp_close(). Good point, I'll make the comment edit.
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index e9bc9fcc7ea5..e8b435870d6b 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -2249,10 +2249,12 @@ static void binder_deferred_fd_close(int fd) return; init_task_work(&twcb->twork, binder_do_fd_close); __close_fd_get_file(fd, &twcb->file); - if (twcb->file) + if (twcb->file) { + filp_close(twcb->file, current->files); task_work_add(current, &twcb->twork, true); - else + } else { kfree(twcb); + } } static void binder_transaction_buffer_release(struct binder_proc *proc, diff --git a/fs/file.c b/fs/file.c index 3da91a112bab..a250d291c71b 100644 --- a/fs/file.c +++ b/fs/file.c @@ -662,7 +662,7 @@ int __close_fd_get_file(unsigned int fd, struct file **res) spin_unlock(&files->file_lock); get_file(file); *res = file; - return filp_close(file, files); + return 0; out_unlock: spin_unlock(&files->file_lock);
Just one caller of this, and just use filp_close() there manually. This is important to allow async close/removal of the fd. Signed-off-by: Jens Axboe <axboe@kernel.dk> --- drivers/android/binder.c | 6 ++++-- fs/file.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)