mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
convert media_request_get_by_fd()
the only thing done after fdput() (in failure cases) is a printk; safely transposable with fdput()... Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
00ec41ac16
commit
44b11a56c3
@ -246,22 +246,21 @@ static const struct file_operations request_fops = {
|
|||||||
struct media_request *
|
struct media_request *
|
||||||
media_request_get_by_fd(struct media_device *mdev, int request_fd)
|
media_request_get_by_fd(struct media_device *mdev, int request_fd)
|
||||||
{
|
{
|
||||||
struct fd f;
|
|
||||||
struct media_request *req;
|
struct media_request *req;
|
||||||
|
|
||||||
if (!mdev || !mdev->ops ||
|
if (!mdev || !mdev->ops ||
|
||||||
!mdev->ops->req_validate || !mdev->ops->req_queue)
|
!mdev->ops->req_validate || !mdev->ops->req_queue)
|
||||||
return ERR_PTR(-EBADR);
|
return ERR_PTR(-EBADR);
|
||||||
|
|
||||||
f = fdget(request_fd);
|
CLASS(fd, f)(request_fd);
|
||||||
if (!fd_file(f))
|
if (fd_empty(f))
|
||||||
goto err_no_req_fd;
|
goto err;
|
||||||
|
|
||||||
if (fd_file(f)->f_op != &request_fops)
|
if (fd_file(f)->f_op != &request_fops)
|
||||||
goto err_fput;
|
goto err;
|
||||||
req = fd_file(f)->private_data;
|
req = fd_file(f)->private_data;
|
||||||
if (req->mdev != mdev)
|
if (req->mdev != mdev)
|
||||||
goto err_fput;
|
goto err;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: as long as someone has an open filehandle of the request,
|
* Note: as long as someone has an open filehandle of the request,
|
||||||
@ -272,14 +271,9 @@ media_request_get_by_fd(struct media_device *mdev, int request_fd)
|
|||||||
* before media_request_get() is called.
|
* before media_request_get() is called.
|
||||||
*/
|
*/
|
||||||
media_request_get(req);
|
media_request_get(req);
|
||||||
fdput(f);
|
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
|
|
||||||
err_fput:
|
err:
|
||||||
fdput(f);
|
|
||||||
|
|
||||||
err_no_req_fd:
|
|
||||||
dev_dbg(mdev->dev, "cannot find request_fd %d\n", request_fd);
|
dev_dbg(mdev->dev, "cannot find request_fd %d\n", request_fd);
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user