aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2019-04-14 12:55:07 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2019-05-02 02:25:54 -0400
commit3b85d3028e2a0f95a8425fbfa54a04056b7cbc91 (patch)
tree719aa59a08b2f08e2e98b4be0e28b7adaeb556c6
parentfb3862435335633edef924c2e7f2820b4c561325 (diff)
media: switch to fdget()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/media/media-request.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/media/media-request.c b/drivers/media/media-request.c
index eec2e2b2f6ec..9e5fd2ac769e 100644
--- a/drivers/media/media-request.c
+++ b/drivers/media/media-request.c
@@ -246,38 +246,38 @@ static const struct file_operations request_fops = {
246struct media_request * 246struct media_request *
247media_request_get_by_fd(struct media_device *mdev, int request_fd) 247media_request_get_by_fd(struct media_device *mdev, int request_fd)
248{ 248{
249 struct file *filp; 249 struct fd f;
250 struct media_request *req; 250 struct media_request *req;
251 251
252 if (!mdev || !mdev->ops || 252 if (!mdev || !mdev->ops ||
253 !mdev->ops->req_validate || !mdev->ops->req_queue) 253 !mdev->ops->req_validate || !mdev->ops->req_queue)
254 return ERR_PTR(-EACCES); 254 return ERR_PTR(-EACCES);
255 255
256 filp = fget(request_fd); 256 f = fdget(request_fd);
257 if (!filp) 257 if (!f.file)
258 goto err_no_req_fd; 258 goto err_no_req_fd;
259 259
260 if (filp->f_op != &request_fops) 260 if (f.file->f_op != &request_fops)
261 goto err_fput; 261 goto err_fput;
262 req = filp->private_data; 262 req = f.file->private_data;
263 if (req->mdev != mdev) 263 if (req->mdev != mdev)
264 goto err_fput; 264 goto err_fput;
265 265
266 /* 266 /*
267 * Note: as long as someone has an open filehandle of the request, 267 * Note: as long as someone has an open filehandle of the request,
268 * the request can never be released. The fget() above ensures that 268 * the request can never be released. The fdget() above ensures that
269 * even if userspace closes the request filehandle, the release() 269 * even if userspace closes the request filehandle, the release()
270 * fop won't be called, so the media_request_get() always succeeds 270 * fop won't be called, so the media_request_get() always succeeds
271 * and there is no race condition where the request was released 271 * and there is no race condition where the request was released
272 * before media_request_get() is called. 272 * before media_request_get() is called.
273 */ 273 */
274 media_request_get(req); 274 media_request_get(req);
275 fput(filp); 275 fdput(f);
276 276
277 return req; 277 return req;
278 278
279err_fput: 279err_fput:
280 fput(filp); 280 fdput(f);
281 281
282err_no_req_fd: 282err_no_req_fd:
283 dev_dbg(mdev->dev, "cannot find request_fd %d\n", request_fd); 283 dev_dbg(mdev->dev, "cannot find request_fd %d\n", request_fd);