mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user()
@ 2026-07-05 11:02 mdshahid03
  2026-07-24 12:22 ` mdshahid03
  2026-08-19 12:50 ` Inki Dae
  0 siblings, 2 replies; 5+ messages in thread
From: mdshahid03 @ 2026-07-05 11:02 UTC (permalink / raw)
  To: Inki Dae, Seung-Woo Kim, Kyungmin Park, David Airlie,
	Simona Vetter, Krzysztof Kozlowski, Peter Griffin
  Cc: Alim Akhtar, dri-devel, linux-arm-kernel, linux-samsung-soc,
	linux-kernel, Mohammad Shahid

From: Mohammad Shahid <mdshahid03@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@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);
 
 		drm_edid = drm_edid_alloc(edid_buf, size);
 		kfree(edid_buf);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user()
  2026-07-05 11:02 [PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user() mdshahid03
@ 2026-07-24 12:22 ` mdshahid03
  2026-07-31 15:17   ` Inki Dae
  2026-08-19 12:50 ` Inki Dae
  1 sibling, 1 reply; 5+ messages in thread
From: mdshahid03 @ 2026-07-24 12:22 UTC (permalink / raw)
  To: Inki Dae, Seung-Woo Kim, Kyungmin Park, David Airlie,
	Simona Vetter, Krzysztof Kozlowski, Peter Griffin
  Cc: Alim Akhtar, dri-devel, linux-arm-kernel, linux-samsung-soc,
	linux-kernel

Hi,

Gentle ping on this patch.

Could please take a look when time permits?

Thanks!

Mohammad Shahid


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user()
  2026-07-24 12:22 ` mdshahid03
@ 2026-07-31 15:17   ` Inki Dae
  2026-08-17 16:12     ` mdshahid03
  0 siblings, 1 reply; 5+ messages in thread
From: Inki Dae @ 2026-07-31 15:17 UTC (permalink / raw)
  To: mdshahid03
  Cc: Seung-Woo Kim, Kyungmin Park, David Airlie, Simona Vetter,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Hi,

Thanks for your contribution. I will review it soon.

Thanks,
Inki Dae

2026년 7월 24일 (금) 오후 9:27, <mdshahid03@gmail.com>님이 작성:
>
> Hi,
>
> Gentle ping on this patch.
>
> Could please take a look when time permits?
>
> Thanks!
>
> Mohammad Shahid
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user()
  2026-07-31 15:17   ` Inki Dae
@ 2026-08-17 16:12     ` mdshahid03
  0 siblings, 0 replies; 5+ messages in thread
From: mdshahid03 @ 2026-08-17 16:12 UTC (permalink / raw)
  To: daeinki
  Cc: airlied, alim.akhtar, dri-devel, krzk, kyungmin.park,
	linux-arm-kernel, linux-kernel, linux-samsung-soc, peter.griffin,
	simona, sw0312.kim

Hi Inki,

Thanks for the response. I appreciate you taking the time to review the patch.

For context, a similar cleanup patch of mine was recently accepted by Greg KH and is now in linux-next.

Thanks,
Shahid


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user()
  2026-07-05 11:02 [PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user() mdshahid03
  2026-07-24 12:22 ` mdshahid03
@ 2026-08-19 12:50 ` Inki Dae
  1 sibling, 0 replies; 5+ messages in thread
From: Inki Dae @ 2026-08-19 12:50 UTC (permalink / raw)
  To: mdshahid03
  Cc: Seung-Woo Kim, Kyungmin Park, David Airlie, Simona Vetter,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-kernel

Sorry for being late.

2026년 7월 5일 (일) 오후 8:02, <mdshahid03@gmail.com>님이 작성:
>
> From: Mohammad Shahid <mdshahid03@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@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
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-19 12:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-05 11:02 [PATCH] drm/exynos: vidi: use memdup_user() instead of kmalloc() and copy_from_user() mdshahid03
2026-07-24 12:22 ` mdshahid03
2026-07-31 15:17   ` Inki Dae
2026-08-17 16:12     ` mdshahid03
2026-08-19 12:50 ` Inki Dae

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®