[PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user()

Inki Dae daeinki at gmail.com
Wed Aug 19 05:50:57 PDT 2026


Sorry for being late.

2026년 7월 5일 (일) 오후 8:02, <mdshahid03 at gmail.com>님이 작성:
>
> From: Mohammad Shahid <mdshahid03 at gmail.com>
>
> Use memdup_user() to replace the open-coded kmalloc() and
> copy_from_user() sequence.
>
> This simplifies the code while preserving the existing behavior.
>
> This issue was reported by memdup_user.cocci.
>
> Signed-off-by: Mohammad Shahid <mdshahid03 at gmail.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_vidi.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> index 67bbf9b8bc0e..183671de711e 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> @@ -273,14 +273,9 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
>
>                 size = (hdr.extensions + 1) * EDID_LENGTH;
>
> -               edid_buf = kmalloc(size, GFP_KERNEL);
> -               if (!edid_buf)
> -                       return -ENOMEM;
> -
> -               if (copy_from_user(edid_buf, edid_userptr, size)) {
> -                       kfree(edid_buf);
> -                       return -EFAULT;
> -               }
> +               edid_buf = memdup_user(edid_userptr, size);
> +               if (IS_ERR(edid_buf))
> +                       return PTR_ERR(edid_buf);

exynos_drm_vidi.c does not include <linux/string.h>, where
memdup_user() is declared. It only builds today because the header is
pulled in transitively. You would add the include explicitly.

This is a trivial thing so I can handle it.

 Merged. Thanks,
Inki Dae

>
>                 drm_edid = drm_edid_alloc(edid_buf, size);
>                 kfree(edid_buf);
> --
> 2.43.0
>
>



More information about the linux-arm-kernel mailing list