Skip to content

Commit f8ffbc3

Browse files
committed
Merge tag 'pull-stable-struct_fd' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull 'struct fd' updates from Al Viro: "Just the 'struct fd' layout change, with conversion to accessor helpers" * tag 'pull-stable-struct_fd' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: add struct fd constructors, get rid of __to_fd() struct fd: representation change introduce fd_file(), convert all accessors to it.
2 parents f8eb5bd + de12c33 commit f8ffbc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+562
-559
lines changed

arch/alpha/kernel/osf_sys.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
160160
.count = count
161161
};
162162

163-
if (!arg.file)
163+
if (!fd_file(arg))
164164
return -EBADF;
165165

166-
error = iterate_dir(arg.file, &buf.ctx);
166+
error = iterate_dir(fd_file(arg), &buf.ctx);
167167
if (error >= 0)
168168
error = buf.error;
169169
if (count != buf.count)

arch/arm/kernel/sys_oabi-compat.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,33 +239,33 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
239239
struct flock64 flock;
240240
long err = -EBADF;
241241

242-
if (!f.file)
242+
if (!fd_file(f))
243243
goto out;
244244

245245
switch (cmd) {
246246
case F_GETLK64:
247247
case F_OFD_GETLK:
248-
err = security_file_fcntl(f.file, cmd, arg);
248+
err = security_file_fcntl(fd_file(f), cmd, arg);
249249
if (err)
250250
break;
251251
err = get_oabi_flock(&flock, argp);
252252
if (err)
253253
break;
254-
err = fcntl_getlk64(f.file, cmd, &flock);
254+
err = fcntl_getlk64(fd_file(f), cmd, &flock);
255255
if (!err)
256256
err = put_oabi_flock(&flock, argp);
257257
break;
258258
case F_SETLK64:
259259
case F_SETLKW64:
260260
case F_OFD_SETLK:
261261
case F_OFD_SETLKW:
262-
err = security_file_fcntl(f.file, cmd, arg);
262+
err = security_file_fcntl(fd_file(f), cmd, arg);
263263
if (err)
264264
break;
265265
err = get_oabi_flock(&flock, argp);
266266
if (err)
267267
break;
268-
err = fcntl_setlk64(fd, f.file, cmd, &flock);
268+
err = fcntl_setlk64(fd, fd_file(f), cmd, &flock);
269269
break;
270270
default:
271271
err = sys_fcntl64(fd, cmd, arg);

arch/powerpc/kvm/book3s_64_vio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
118118
struct fd f;
119119

120120
f = fdget(tablefd);
121-
if (!f.file)
121+
if (!fd_file(f))
122122
return -EBADF;
123123

124124
rcu_read_lock();
125125
list_for_each_entry_rcu(stt, &kvm->arch.spapr_tce_tables, list) {
126-
if (stt == f.file->private_data) {
126+
if (stt == fd_file(f)->private_data) {
127127
found = true;
128128
break;
129129
}

arch/powerpc/kvm/powerpc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,11 +1938,11 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
19381938

19391939
r = -EBADF;
19401940
f = fdget(cap->args[0]);
1941-
if (!f.file)
1941+
if (!fd_file(f))
19421942
break;
19431943

19441944
r = -EPERM;
1945-
dev = kvm_device_from_filp(f.file);
1945+
dev = kvm_device_from_filp(fd_file(f));
19461946
if (dev)
19471947
r = kvmppc_mpic_connect_vcpu(dev, vcpu, cap->args[1]);
19481948

@@ -1957,11 +1957,11 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
19571957

19581958
r = -EBADF;
19591959
f = fdget(cap->args[0]);
1960-
if (!f.file)
1960+
if (!fd_file(f))
19611961
break;
19621962

19631963
r = -EPERM;
1964-
dev = kvm_device_from_filp(f.file);
1964+
dev = kvm_device_from_filp(fd_file(f));
19651965
if (dev) {
19661966
if (xics_on_xive())
19671967
r = kvmppc_xive_connect_vcpu(dev, vcpu, cap->args[1]);
@@ -1980,7 +1980,7 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
19801980

19811981
r = -EBADF;
19821982
f = fdget(cap->args[0]);
1983-
if (!f.file)
1983+
if (!fd_file(f))
19841984
break;
19851985

19861986
r = -ENXIO;
@@ -1990,7 +1990,7 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
19901990
}
19911991

19921992
r = -EPERM;
1993-
dev = kvm_device_from_filp(f.file);
1993+
dev = kvm_device_from_filp(fd_file(f));
19941994
if (dev)
19951995
r = kvmppc_xive_native_connect_vcpu(dev, vcpu,
19961996
cap->args[1]);

arch/powerpc/platforms/cell/spu_syscalls.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags,
6666
if (flags & SPU_CREATE_AFFINITY_SPU) {
6767
struct fd neighbor = fdget(neighbor_fd);
6868
ret = -EBADF;
69-
if (neighbor.file) {
70-
ret = calls->create_thread(name, flags, mode, neighbor.file);
69+
if (fd_file(neighbor)) {
70+
ret = calls->create_thread(name, flags, mode, fd_file(neighbor));
7171
fdput(neighbor);
7272
}
7373
} else
@@ -89,8 +89,8 @@ SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, ustatus)
8989

9090
ret = -EBADF;
9191
arg = fdget(fd);
92-
if (arg.file) {
93-
ret = calls->spu_run(arg.file, unpc, ustatus);
92+
if (fd_file(arg)) {
93+
ret = calls->spu_run(fd_file(arg), unpc, ustatus);
9494
fdput(arg);
9595
}
9696

arch/x86/kernel/cpu/sgx/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,10 @@ int sgx_set_attribute(unsigned long *allowed_attributes,
903903
{
904904
struct fd f = fdget(attribute_fd);
905905

906-
if (!f.file)
906+
if (!fd_file(f))
907907
return -EINVAL;
908908

909-
if (f.file->f_op != &sgx_provision_fops) {
909+
if (fd_file(f)->f_op != &sgx_provision_fops) {
910910
fdput(f);
911911
return -EINVAL;
912912
}

arch/x86/kvm/svm/sev.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ static int __sev_issue_cmd(int fd, int id, void *data, int *error)
534534
int ret;
535535

536536
f = fdget(fd);
537-
if (!f.file)
537+
if (!fd_file(f))
538538
return -EBADF;
539539

540-
ret = sev_issue_cmd_external_user(f.file, id, data, error);
540+
ret = sev_issue_cmd_external_user(fd_file(f), id, data, error);
541541

542542
fdput(f);
543543
return ret;
@@ -2078,15 +2078,15 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd)
20782078
bool charged = false;
20792079
int ret;
20802080

2081-
if (!f.file)
2081+
if (!fd_file(f))
20822082
return -EBADF;
20832083

2084-
if (!file_is_kvm(f.file)) {
2084+
if (!file_is_kvm(fd_file(f))) {
20852085
ret = -EBADF;
20862086
goto out_fput;
20872087
}
20882088

2089-
source_kvm = f.file->private_data;
2089+
source_kvm = fd_file(f)->private_data;
20902090
ret = sev_lock_two_vms(kvm, source_kvm);
20912091
if (ret)
20922092
goto out_fput;
@@ -2803,15 +2803,15 @@ int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd)
28032803
struct kvm_sev_info *source_sev, *mirror_sev;
28042804
int ret;
28052805

2806-
if (!f.file)
2806+
if (!fd_file(f))
28072807
return -EBADF;
28082808

2809-
if (!file_is_kvm(f.file)) {
2809+
if (!file_is_kvm(fd_file(f))) {
28102810
ret = -EBADF;
28112811
goto e_source_fput;
28122812
}
28132813

2814-
source_kvm = f.file->private_data;
2814+
source_kvm = fd_file(f)->private_data;
28152815
ret = sev_lock_two_vms(kvm, source_kvm);
28162816
if (ret)
28172817
goto e_source_fput;

drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
4242
uint32_t id;
4343
int r;
4444

45-
if (!f.file)
45+
if (!fd_file(f))
4646
return -EINVAL;
4747

48-
r = amdgpu_file_to_fpriv(f.file, &fpriv);
48+
r = amdgpu_file_to_fpriv(fd_file(f), &fpriv);
4949
if (r) {
5050
fdput(f);
5151
return r;
@@ -71,10 +71,10 @@ static int amdgpu_sched_context_priority_override(struct amdgpu_device *adev,
7171
struct amdgpu_ctx *ctx;
7272
int r;
7373

74-
if (!f.file)
74+
if (!fd_file(f))
7575
return -EINVAL;
7676

77-
r = amdgpu_file_to_fpriv(f.file, &fpriv);
77+
r = amdgpu_file_to_fpriv(fd_file(f), &fpriv);
7878
if (r) {
7979
fdput(f);
8080
return r;

drivers/gpu/drm/drm_syncobj.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,16 +715,16 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private,
715715
struct fd f = fdget(fd);
716716
int ret;
717717

718-
if (!f.file)
718+
if (!fd_file(f))
719719
return -EINVAL;
720720

721-
if (f.file->f_op != &drm_syncobj_file_fops) {
721+
if (fd_file(f)->f_op != &drm_syncobj_file_fops) {
722722
fdput(f);
723723
return -EINVAL;
724724
}
725725

726726
/* take a reference to put in the idr */
727-
syncobj = f.file->private_data;
727+
syncobj = fd_file(f)->private_data;
728728
drm_syncobj_get(syncobj);
729729

730730
idr_preload(GFP_KERNEL);

drivers/infiniband/core/ucma.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,13 +1624,13 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
16241624

16251625
/* Get current fd to protect against it being closed */
16261626
f = fdget(cmd.fd);
1627-
if (!f.file)
1627+
if (!fd_file(f))
16281628
return -ENOENT;
1629-
if (f.file->f_op != &ucma_fops) {
1629+
if (fd_file(f)->f_op != &ucma_fops) {
16301630
ret = -EINVAL;
16311631
goto file_put;
16321632
}
1633-
cur_file = f.file->private_data;
1633+
cur_file = fd_file(f)->private_data;
16341634

16351635
/* Validate current fd and prevent destruction of id. */
16361636
ctx = ucma_get_ctx(cur_file, cmd.id);

0 commit comments

Comments
 (0)