[media] vivid-vid-out: use memdup_user()
Author: Mauro Carvalho Chehab <m.chehab@samsung.com>
Instead of allocating and coping from __user, do it using
one atomic call. That makes the code simpler.
Found by coccinelle.
Acked-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
---
drivers/media/platform/vivid/vivid-vid-out.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
index c983461..8ed9f6d 100644
--- a/drivers/media/platform/vivid/vivid-vid-out.c
+++ b/drivers/media/platform/vivid/vivid-vid-out.c
@@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
return ret;
if (win->bitmap) {
- new_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
+ new_bitmap = memdup_user(win->bitmap, bitmap_size);
- if (new_bitmap == NULL)
- return -ENOMEM;
- if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
- kfree(new_bitmap);
- return -EFAULT;
- }
+ if (IS_ERR(new_bitmap))
+ return PTR_ERR(new_bitmap);
}
dev->overlay_out_top = win->w.top; |
---
drivers/media/platform/vivid/vivid-vid-out.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
index c983461..8ed9f6d 100644
--- a/drivers/media/platform/vivid/vivid-vid-out.c
+++ b/drivers/media/platform/vivid/vivid-vid-out.c
@@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
return ret;
if (win->bitmap) {
- new_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
+ new_bitmap = memdup_user(win->bitmap, bitmap_size);
- if (new_bitmap == NULL)
- return -ENOMEM;
- if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
- kfree(new_bitmap);
- return -EFAULT;
- }
+ if (IS_ERR(new_bitmap))
+ return PTR_ERR(new_bitmap);
}
dev->overlay_out_top = win->w.top;