diff options
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-compat-ioctl32.c')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index 83ffb6436baf..cc5998b31463 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c | |||
@@ -297,6 +297,7 @@ struct v4l2_plane32 { | |||
297 | union { | 297 | union { |
298 | __u32 mem_offset; | 298 | __u32 mem_offset; |
299 | compat_long_t userptr; | 299 | compat_long_t userptr; |
300 | __s32 fd; | ||
300 | } m; | 301 | } m; |
301 | __u32 data_offset; | 302 | __u32 data_offset; |
302 | __u32 reserved[11]; | 303 | __u32 reserved[11]; |
@@ -318,6 +319,7 @@ struct v4l2_buffer32 { | |||
318 | __u32 offset; | 319 | __u32 offset; |
319 | compat_long_t userptr; | 320 | compat_long_t userptr; |
320 | compat_caddr_t planes; | 321 | compat_caddr_t planes; |
322 | __s32 fd; | ||
321 | } m; | 323 | } m; |
322 | __u32 length; | 324 | __u32 length; |
323 | __u32 reserved2; | 325 | __u32 reserved2; |
@@ -341,6 +343,9 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32, | |||
341 | up_pln = compat_ptr(p); | 343 | up_pln = compat_ptr(p); |
342 | if (put_user((unsigned long)up_pln, &up->m.userptr)) | 344 | if (put_user((unsigned long)up_pln, &up->m.userptr)) |
343 | return -EFAULT; | 345 | return -EFAULT; |
346 | } else if (memory == V4L2_MEMORY_DMABUF) { | ||
347 | if (copy_in_user(&up->m.fd, &up32->m.fd, sizeof(int))) | ||
348 | return -EFAULT; | ||
344 | } else { | 349 | } else { |
345 | if (copy_in_user(&up->m.mem_offset, &up32->m.mem_offset, | 350 | if (copy_in_user(&up->m.mem_offset, &up32->m.mem_offset, |
346 | sizeof(__u32))) | 351 | sizeof(__u32))) |
@@ -364,6 +369,11 @@ static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32, | |||
364 | if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset, | 369 | if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset, |
365 | sizeof(__u32))) | 370 | sizeof(__u32))) |
366 | return -EFAULT; | 371 | return -EFAULT; |
372 | /* For DMABUF, driver might've set up the fd, so copy it back. */ | ||
373 | if (memory == V4L2_MEMORY_DMABUF) | ||
374 | if (copy_in_user(&up32->m.fd, &up->m.fd, | ||
375 | sizeof(int))) | ||
376 | return -EFAULT; | ||
367 | 377 | ||
368 | return 0; | 378 | return 0; |
369 | } | 379 | } |
@@ -446,6 +456,10 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user | |||
446 | if (get_user(kp->m.offset, &up->m.offset)) | 456 | if (get_user(kp->m.offset, &up->m.offset)) |
447 | return -EFAULT; | 457 | return -EFAULT; |
448 | break; | 458 | break; |
459 | case V4L2_MEMORY_DMABUF: | ||
460 | if (get_user(kp->m.fd, &up->m.fd)) | ||
461 | return -EFAULT; | ||
462 | break; | ||
449 | } | 463 | } |
450 | } | 464 | } |
451 | 465 | ||
@@ -510,6 +524,10 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user | |||
510 | if (put_user(kp->m.offset, &up->m.offset)) | 524 | if (put_user(kp->m.offset, &up->m.offset)) |
511 | return -EFAULT; | 525 | return -EFAULT; |
512 | break; | 526 | break; |
527 | case V4L2_MEMORY_DMABUF: | ||
528 | if (put_user(kp->m.fd, &up->m.fd)) | ||
529 | return -EFAULT; | ||
530 | break; | ||
513 | } | 531 | } |
514 | } | 532 | } |
515 | 533 | ||