From: Sakari Ailus Date: Sun, 20 Dec 2020 20:17:17 +0000 (+0100) Subject: media: v4l: ioctl: Use kmalloc to allocate a small chunk of memory X-Git-Tag: v5.15~1736^2~278 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62a1255152be2cb4291fb3f0208bd837d33a8e2d;p=platform%2Fkernel%2Flinux-starfive.git media: v4l: ioctl: Use kmalloc to allocate a small chunk of memory kvmalloc() was used to allocate the temporary memory buffer that was used to contain both the IOCTL argument as well as a possible array argument that could have been large. Now that the two are separated, the IOCTL argument is known to be small in size. Use kmalloc to allocate it instead of kvmalloc. Similarly for releasing it. Suggested-by: Arnd Bergmann Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 9906b41..8d5d9c3 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -3300,7 +3300,7 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg, parg = sbuf; } else { /* too big to allocate from stack */ - mbuf = kvmalloc(ioc_size, GFP_KERNEL); + mbuf = kmalloc(ioc_size, GFP_KERNEL); if (NULL == mbuf) return -ENOMEM; parg = mbuf; @@ -3377,7 +3377,7 @@ out_array_args: err = -EFAULT; out: kvfree(array_buf); - kvfree(mbuf); + kfree(mbuf); return err; }