aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-08-28 12:52:22 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-26 22:20:08 -0400
commit2903ff019b346ab8d36ebbf54853c3aaf6590608 (patch)
tree962d94054765bb37bc00e977c3036e65c5fd91fe /drivers
parenta5b470ba06aa3f96999ede5feba178df6bdb134a (diff)
switch simple cases of fget_light to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/core/ucma.c12
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c18
-rw-r--r--drivers/infiniband/core/uverbs_main.c12
-rw-r--r--drivers/vfio/vfio.c17
-rw-r--r--drivers/video/msm/mdp.c12
5 files changed, 33 insertions, 38 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);
1233file_put: 1233file_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
827err_tree_mutex_unlock: 827err_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,
541struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd) 541struct 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
562out: 560out:
563 fput_light(filp, fput_needed); 561 fdput(f);
564 return ev_file; 562 return ev_file;
565} 563}
566 564
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 91bcd97d3061..56097c6d072d 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -1014,25 +1014,25 @@ static void vfio_group_try_dissolve_container(struct vfio_group *group)
1014 1014
1015static int vfio_group_set_container(struct vfio_group *group, int container_fd) 1015static int vfio_group_set_container(struct vfio_group *group, int container_fd)
1016{ 1016{
1017 struct file *filep; 1017 struct fd f;
1018 struct vfio_container *container; 1018 struct vfio_container *container;
1019 struct vfio_iommu_driver *driver; 1019 struct vfio_iommu_driver *driver;
1020 int ret = 0, fput_needed; 1020 int ret = 0;
1021 1021
1022 if (atomic_read(&group->container_users)) 1022 if (atomic_read(&group->container_users))
1023 return -EINVAL; 1023 return -EINVAL;
1024 1024
1025 filep = fget_light(container_fd, &fput_needed); 1025 f = fdget(container_fd);
1026 if (!filep) 1026 if (!f.file)
1027 return -EBADF; 1027 return -EBADF;
1028 1028
1029 /* Sanity check, is this really our fd? */ 1029 /* Sanity check, is this really our fd? */
1030 if (filep->f_op != &vfio_fops) { 1030 if (f.file->f_op != &vfio_fops) {
1031 fput_light(filep, fput_needed); 1031 fdput(f);
1032 return -EINVAL; 1032 return -EINVAL;
1033 } 1033 }
1034 1034
1035 container = filep->private_data; 1035 container = f.file->private_data;
1036 WARN_ON(!container); /* fget ensures we don't race vfio_release */ 1036 WARN_ON(!container); /* fget ensures we don't race vfio_release */
1037 1037
1038 mutex_lock(&container->group_lock); 1038 mutex_lock(&container->group_lock);
@@ -1054,8 +1054,7 @@ static int vfio_group_set_container(struct vfio_group *group, int container_fd)
1054 1054
1055unlock_out: 1055unlock_out:
1056 mutex_unlock(&container->group_lock); 1056 mutex_unlock(&container->group_lock);
1057 fput_light(filep, fput_needed); 1057 fdput(f);
1058
1059 return ret; 1058 return ret;
1060} 1059}
1061 1060
diff --git a/drivers/video/msm/mdp.c b/drivers/video/msm/mdp.c
index cb2ddf164c98..07c9d8ab2c3b 100644
--- a/drivers/video/msm/mdp.c
+++ b/drivers/video/msm/mdp.c
@@ -257,19 +257,17 @@ int get_img(struct mdp_img *img, struct fb_info *info,
257 unsigned long *start, unsigned long *len, 257 unsigned long *start, unsigned long *len,
258 struct file **filep) 258 struct file **filep)
259{ 259{
260 int put_needed, ret = 0; 260 int ret = 0;
261 struct file *file; 261 struct fd f = fdget(img->memory_id);
262 262 if (f.file == NULL)
263 file = fget_light(img->memory_id, &put_needed);
264 if (file == NULL)
265 return -1; 263 return -1;
266 264
267 if (MAJOR(file->f_dentry->d_inode->i_rdev) == FB_MAJOR) { 265 if (MAJOR(f.file->f_dentry->d_inode->i_rdev) == FB_MAJOR) {
268 *start = info->fix.smem_start; 266 *start = info->fix.smem_start;
269 *len = info->fix.smem_len; 267 *len = info->fix.smem_len;
270 } else 268 } else
271 ret = -1; 269 ret = -1;
272 fput_light(file, put_needed); 270 fdput(f);
273 271
274 return ret; 272 return ret;
275} 273}