diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-08-28 12:52:22 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-26 22:20:08 -0400 |
commit | 2903ff019b346ab8d36ebbf54853c3aaf6590608 (patch) | |
tree | 962d94054765bb37bc00e977c3036e65c5fd91fe /drivers/infiniband | |
parent | a5b470ba06aa3f96999ede5feba178df6bdb134a (diff) |
switch simple cases of fget_light to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/ucma.c | 12 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 18 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_main.c | 12 |
3 files changed, 20 insertions, 22 deletions
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 6b2ae729de92..6f28da9f4cad 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c | |||
@@ -1184,20 +1184,20 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file, | |||
1184 | struct rdma_ucm_migrate_id cmd; | 1184 | struct rdma_ucm_migrate_id cmd; |
1185 | struct rdma_ucm_migrate_resp resp; | 1185 | struct rdma_ucm_migrate_resp resp; |
1186 | struct ucma_context *ctx; | 1186 | struct ucma_context *ctx; |
1187 | struct file *filp; | 1187 | struct fd f; |
1188 | struct ucma_file *cur_file; | 1188 | struct ucma_file *cur_file; |
1189 | int ret = 0, fput_needed; | 1189 | int ret = 0; |
1190 | 1190 | ||
1191 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) | 1191 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) |
1192 | return -EFAULT; | 1192 | return -EFAULT; |
1193 | 1193 | ||
1194 | /* Get current fd to protect against it being closed */ | 1194 | /* Get current fd to protect against it being closed */ |
1195 | filp = fget_light(cmd.fd, &fput_needed); | 1195 | f = fdget(cmd.fd); |
1196 | if (!filp) | 1196 | if (!f.file) |
1197 | return -ENOENT; | 1197 | return -ENOENT; |
1198 | 1198 | ||
1199 | /* Validate current fd and prevent destruction of id. */ | 1199 | /* Validate current fd and prevent destruction of id. */ |
1200 | ctx = ucma_get_ctx(filp->private_data, cmd.id); | 1200 | ctx = ucma_get_ctx(f.file->private_data, cmd.id); |
1201 | if (IS_ERR(ctx)) { | 1201 | if (IS_ERR(ctx)) { |
1202 | ret = PTR_ERR(ctx); | 1202 | ret = PTR_ERR(ctx); |
1203 | goto file_put; | 1203 | goto file_put; |
@@ -1231,7 +1231,7 @@ response: | |||
1231 | 1231 | ||
1232 | ucma_put_ctx(ctx); | 1232 | ucma_put_ctx(ctx); |
1233 | file_put: | 1233 | file_put: |
1234 | fput_light(filp, fput_needed); | 1234 | fdput(f); |
1235 | return ret; | 1235 | return ret; |
1236 | } | 1236 | } |
1237 | 1237 | ||
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 402679bd30a3..0cb0007724a2 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -705,9 +705,9 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, | |||
705 | struct ib_udata udata; | 705 | struct ib_udata udata; |
706 | struct ib_uxrcd_object *obj; | 706 | struct ib_uxrcd_object *obj; |
707 | struct ib_xrcd *xrcd = NULL; | 707 | struct ib_xrcd *xrcd = NULL; |
708 | struct file *f = NULL; | 708 | struct fd f = {NULL, 0}; |
709 | struct inode *inode = NULL; | 709 | struct inode *inode = NULL; |
710 | int ret = 0, fput_needed; | 710 | int ret = 0; |
711 | int new_xrcd = 0; | 711 | int new_xrcd = 0; |
712 | 712 | ||
713 | if (out_len < sizeof resp) | 713 | if (out_len < sizeof resp) |
@@ -724,13 +724,13 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, | |||
724 | 724 | ||
725 | if (cmd.fd != -1) { | 725 | if (cmd.fd != -1) { |
726 | /* search for file descriptor */ | 726 | /* search for file descriptor */ |
727 | f = fget_light(cmd.fd, &fput_needed); | 727 | f = fdget(cmd.fd); |
728 | if (!f) { | 728 | if (!f.file) { |
729 | ret = -EBADF; | 729 | ret = -EBADF; |
730 | goto err_tree_mutex_unlock; | 730 | goto err_tree_mutex_unlock; |
731 | } | 731 | } |
732 | 732 | ||
733 | inode = f->f_dentry->d_inode; | 733 | inode = f.file->f_path.dentry->d_inode; |
734 | xrcd = find_xrcd(file->device, inode); | 734 | xrcd = find_xrcd(file->device, inode); |
735 | if (!xrcd && !(cmd.oflags & O_CREAT)) { | 735 | if (!xrcd && !(cmd.oflags & O_CREAT)) { |
736 | /* no file descriptor. Need CREATE flag */ | 736 | /* no file descriptor. Need CREATE flag */ |
@@ -795,8 +795,8 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, | |||
795 | goto err_copy; | 795 | goto err_copy; |
796 | } | 796 | } |
797 | 797 | ||
798 | if (f) | 798 | if (f.file) |
799 | fput_light(f, fput_needed); | 799 | fdput(f); |
800 | 800 | ||
801 | mutex_lock(&file->mutex); | 801 | mutex_lock(&file->mutex); |
802 | list_add_tail(&obj->uobject.list, &file->ucontext->xrcd_list); | 802 | list_add_tail(&obj->uobject.list, &file->ucontext->xrcd_list); |
@@ -825,8 +825,8 @@ err: | |||
825 | put_uobj_write(&obj->uobject); | 825 | put_uobj_write(&obj->uobject); |
826 | 826 | ||
827 | err_tree_mutex_unlock: | 827 | err_tree_mutex_unlock: |
828 | if (f) | 828 | if (f.file) |
829 | fput_light(f, fput_needed); | 829 | fdput(f); |
830 | 830 | ||
831 | mutex_unlock(&file->device->xrcd_tree_mutex); | 831 | mutex_unlock(&file->device->xrcd_tree_mutex); |
832 | 832 | ||
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index acf75c2cf7ef..6f2ce6fa98f8 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -541,17 +541,15 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file, | |||
541 | struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd) | 541 | struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd) |
542 | { | 542 | { |
543 | struct ib_uverbs_event_file *ev_file = NULL; | 543 | struct ib_uverbs_event_file *ev_file = NULL; |
544 | struct file *filp; | 544 | struct fd f = fdget(fd); |
545 | int fput_needed; | ||
546 | 545 | ||
547 | filp = fget_light(fd, &fput_needed); | 546 | if (!f.file) |
548 | if (!filp) | ||
549 | return NULL; | 547 | return NULL; |
550 | 548 | ||
551 | if (filp->f_op != &uverbs_event_fops) | 549 | if (f.file->f_op != &uverbs_event_fops) |
552 | goto out; | 550 | goto out; |
553 | 551 | ||
554 | ev_file = filp->private_data; | 552 | ev_file = f.file->private_data; |
555 | if (ev_file->is_async) { | 553 | if (ev_file->is_async) { |
556 | ev_file = NULL; | 554 | ev_file = NULL; |
557 | goto out; | 555 | goto out; |
@@ -560,7 +558,7 @@ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd) | |||
560 | kref_get(&ev_file->ref); | 558 | kref_get(&ev_file->ref); |
561 | 559 | ||
562 | out: | 560 | out: |
563 | fput_light(filp, fput_needed); | 561 | fdput(f); |
564 | return ev_file; | 562 | return ev_file; |
565 | } | 563 | } |
566 | 564 | ||