提交 88b428d6 编写于 作者: A Al Viro

switch infinibarf users of fget() to fget_light()

Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 1d3653a7
...@@ -1186,13 +1186,13 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file, ...@@ -1186,13 +1186,13 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
struct ucma_context *ctx; struct ucma_context *ctx;
struct file *filp; struct file *filp;
struct ucma_file *cur_file; struct ucma_file *cur_file;
int ret = 0; int ret = 0, fput_needed;
if (copy_from_user(&cmd, inbuf, sizeof(cmd))) if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
return -EFAULT; return -EFAULT;
/* Get current fd to protect against it being closed */ /* Get current fd to protect against it being closed */
filp = fget(cmd.fd); filp = fget_light(cmd.fd, &fput_needed);
if (!filp) if (!filp)
return -ENOENT; return -ENOENT;
...@@ -1231,7 +1231,7 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file, ...@@ -1231,7 +1231,7 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
ucma_put_ctx(ctx); ucma_put_ctx(ctx);
file_put: file_put:
fput(filp); fput_light(filp, fput_needed);
return ret; return ret;
} }
......
...@@ -707,7 +707,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, ...@@ -707,7 +707,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
struct ib_xrcd *xrcd = NULL; struct ib_xrcd *xrcd = NULL;
struct file *f = NULL; struct file *f = NULL;
struct inode *inode = NULL; struct inode *inode = NULL;
int ret = 0; int ret = 0, fput_needed;
int new_xrcd = 0; int new_xrcd = 0;
if (out_len < sizeof resp) if (out_len < sizeof resp)
...@@ -724,18 +724,13 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, ...@@ -724,18 +724,13 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
if (cmd.fd != -1) { if (cmd.fd != -1) {
/* search for file descriptor */ /* search for file descriptor */
f = fget(cmd.fd); f = fget_light(cmd.fd, &fput_needed);
if (!f) { if (!f) {
ret = -EBADF; ret = -EBADF;
goto err_tree_mutex_unlock; goto err_tree_mutex_unlock;
} }
inode = f->f_dentry->d_inode; inode = f->f_dentry->d_inode;
if (!inode) {
ret = -EBADF;
goto err_tree_mutex_unlock;
}
xrcd = find_xrcd(file->device, inode); xrcd = find_xrcd(file->device, inode);
if (!xrcd && !(cmd.oflags & O_CREAT)) { if (!xrcd && !(cmd.oflags & O_CREAT)) {
/* no file descriptor. Need CREATE flag */ /* no file descriptor. Need CREATE flag */
...@@ -801,7 +796,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, ...@@ -801,7 +796,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
} }
if (f) if (f)
fput(f); fput_light(f, fput_needed);
mutex_lock(&file->mutex); mutex_lock(&file->mutex);
list_add_tail(&obj->uobject.list, &file->ucontext->xrcd_list); list_add_tail(&obj->uobject.list, &file->ucontext->xrcd_list);
...@@ -831,7 +826,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, ...@@ -831,7 +826,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
err_tree_mutex_unlock: err_tree_mutex_unlock:
if (f) if (f)
fput(f); fput_light(f, fput_needed);
mutex_unlock(&file->device->xrcd_tree_mutex); mutex_unlock(&file->device->xrcd_tree_mutex);
......
...@@ -542,8 +542,9 @@ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd) ...@@ -542,8 +542,9 @@ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
{ {
struct ib_uverbs_event_file *ev_file = NULL; struct ib_uverbs_event_file *ev_file = NULL;
struct file *filp; struct file *filp;
int fput_needed;
filp = fget(fd); filp = fget_light(fd, &fput_needed);
if (!filp) if (!filp)
return NULL; return NULL;
...@@ -559,7 +560,7 @@ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd) ...@@ -559,7 +560,7 @@ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
kref_get(&ev_file->ref); kref_get(&ev_file->ref);
out: out:
fput(filp); fput_light(filp, fput_needed);
return ev_file; return ev_file;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册