diff --git a/fs/fuse/file.c b/fs/fuse/file.c index da73d1e183c4..eb5ae11b6010 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3129,7 +3129,7 @@ static int fuse_file_fadvise(struct file *file, loff_t offset, loff_t len, int a struct fuse_file *ff = file->private_data; if (fuse_is_passthrough(ff)) - return fuse_passthrough_fadvise(ff, offset, len, advice); + return fuse_passthrough_fadvise(file, offset, len, advice); return generic_fadvise(file, offset, len, advice); } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 311252eef2e9..c91af283aef2 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1368,7 +1368,7 @@ ssize_t fuse_passthrough_splice_write(struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags); ssize_t fuse_passthrough_mmap(struct file *file, struct vm_area_struct *vma); -int fuse_passthrough_fadvise(struct fuse_file *ff, loff_t offset, loff_t len, int advice); +int fuse_passthrough_fadvise(struct file *file, loff_t offset, loff_t len, int advice); #ifdef CONFIG_SYSCTL extern int fuse_sysctl_register(void); diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c index 1c1cf1085c9c..0ed964c479d9 100644 --- a/fs/fuse/passthrough.c +++ b/fs/fuse/passthrough.c @@ -159,12 +159,16 @@ ssize_t fuse_passthrough_mmap(struct file *file, struct vm_area_struct *vma) return backing_file_mmap(backing_file, vma, &ctx); } -int fuse_passthrough_fadvise(struct fuse_file *ff, loff_t offset, loff_t len, int advice) +int fuse_passthrough_fadvise(struct file *file, loff_t offset, loff_t len, int advice) { + struct fuse_file *ff = file->private_data; struct file *backing_file = fuse_file_passthrough(ff); const struct cred *old_cred; int ret; + if (!backing_file) + return generic_fadvise(file, offset, len, advice); + old_cred = override_creds(ff->cred); ret = vfs_fadvise(backing_file, offset, len, advice); revert_creds(old_cred);