diff options
author | Arnd Bergmann <arnd@arndb.de> | 2020-10-30 17:55:26 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-11-16 10:31:06 +0100 |
commit | 3f65c6f67e8813448d7e3cfd3470b0f8c15bfaea (patch) | |
tree | 9eb3fb033057c603884fb676066e89feec40d896 /drivers/media/pci/bt8xx/bttv-driver.c | |
parent | media: v4l2: move compat handling for v4l2_buffer (diff) | |
download | linux-3f65c6f67e8813448d7e3cfd3470b0f8c15bfaea.tar.xz linux-3f65c6f67e8813448d7e3cfd3470b0f8c15bfaea.zip |
media: v4l2: allocate v4l2_clip objects early
The v4l2_format based ioctls can have an indirect pointer to an array
of v4l2_clip structures for overlay mode, depending on the 'type' member.
There are only five drivers that use the overlay mode and copy the
data through the __user pointer.
Change the five drivers to use memcpy() instead, and copy the data
in common code using the check_array_args() helpers. This allows
for a subsequent patch that use the same mechanism for compat
ioctl handlers.
Note that there is another pointer for a 'bitmap' that is only
used in the 'vivid' driver and nowhere else. There is no easy
way to use the same trick without adding complexity to the
common code, so this remains a __user pointer.
[hverkuil: fix: CHECK: spaces preferred around that '*' (ctx:VxV)]
[hverkuil: fix: CHECK: Alignment should match open parenthesis]
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/pci/bt8xx/bttv-driver.c')
-rw-r--r-- | drivers/media/pci/bt8xx/bttv-driver.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c index 8824dd0fb331..ef2ead36b70e 100644 --- a/drivers/media/pci/bt8xx/bttv-driver.c +++ b/drivers/media/pci/bt8xx/bttv-driver.c @@ -2143,12 +2143,8 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, clips = kmalloc(size,GFP_KERNEL); if (NULL == clips) return -ENOMEM; - if (n > 0) { - if (copy_from_user(clips,win->clips,sizeof(struct v4l2_clip)*n)) { - kfree(clips); - return -EFAULT; - } - } + if (n > 0) + memcpy(clips, win->clips, sizeof(struct v4l2_clip) * n); /* clip against screen */ if (NULL != btv->fbuf.base) |