linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: atomisp: Use vmemdup_user() instead of open-coding
@ 2025-08-14 13:30 Qianfeng Rong
  2025-08-14 13:42 ` Markus Elfring
  2025-08-20 15:01 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Qianfeng Rong @ 2025-08-14 13:30 UTC (permalink / raw)
  To: Hans de Goede, Mauro Carvalho Chehab, Sakari Ailus,
	Andy Shevchenko, Greg Kroah-Hartman, Hans Verkuil, linux-media,
	linux-kernel, linux-staging
  Cc: Qianfeng Rong

Use vmemdup_user() to get a copy of the user buffer in
atomisp_v4l2_framebuffer_to_css_frame().

Compile-tested only.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 3a4eb4f6d3be..d6fa1605a096 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -3326,14 +3326,10 @@ atomisp_v4l2_framebuffer_to_css_frame(const struct v4l2_framebuffer *arg,
 		goto err;
 	}
 
-	tmp_buf = vmalloc(arg->fmt.sizeimage);
-	if (!tmp_buf) {
-		ret = -ENOMEM;
-		goto err;
-	}
-	if (copy_from_user(tmp_buf, (void __user __force *)arg->base,
-			   arg->fmt.sizeimage)) {
-		ret = -EFAULT;
+	tmp_buf = vmemdup_user((void __user __force *)arg->base,
+			       arg->fmt.sizeimage);
+	if (IS_ERR(tmp_buf)) {
+		ret = PTR_ERR(tmp_buf);
 		goto err;
 	}
 
@@ -3345,7 +3341,8 @@ atomisp_v4l2_framebuffer_to_css_frame(const struct v4l2_framebuffer *arg,
 err:
 	if (ret && res)
 		ia_css_frame_free(res);
-	vfree(tmp_buf);
+	if (!IS_ERR(tmp_buf))
+		kvfree(tmp_buf);
 	if (ret == 0)
 		*result = res;
 	return ret;
-- 
2.34.1


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

* Re: [PATCH] media: atomisp: Use vmemdup_user() instead of open-coding
  2025-08-14 13:30 [PATCH] media: atomisp: Use vmemdup_user() instead of open-coding Qianfeng Rong
@ 2025-08-14 13:42 ` Markus Elfring
  2025-08-14 13:58   ` Greg Kroah-Hartman
  2025-08-20 15:01 ` Andy Shevchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2025-08-14 13:42 UTC (permalink / raw)
  To: Qianfeng Rong, linux-media, linux-staging
  Cc: LKML, Andy Shevchenko, Greg Kroah-Hartman, Hans de Goede,
	Hans Verkuil, Mauro Carvalho Chehab, Sakari Ailus

> Use vmemdup_user() to get a copy of the user buffer in
> atomisp_v4l2_framebuffer_to_css_frame().

Was an information source (like the following) reused here?
https://elixir.bootlin.com/linux/v6.16/source/scripts/coccinelle/api/memdup_user.cocci#L2

Regards,
Markus

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

* Re: [PATCH] media: atomisp: Use vmemdup_user() instead of open-coding
  2025-08-14 13:42 ` Markus Elfring
@ 2025-08-14 13:58   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2025-08-14 13:58 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Qianfeng Rong, linux-media, linux-staging, LKML, Andy Shevchenko,
	Hans de Goede, Hans Verkuil, Mauro Carvalho Chehab, Sakari Ailus

On Thu, Aug 14, 2025 at 03:42:33PM +0200, Markus Elfring wrote:
> > Use vmemdup_user() to get a copy of the user buffer in
> > atomisp_v4l2_framebuffer_to_css_frame().
> 
> Was an information source (like the following) reused here?
> https://elixir.bootlin.com/linux/v6.16/source/scripts/coccinelle/api/memdup_user.cocci#L2
> 
> Regards,
> Markus

Hi,

This is the semi-friendly patch-bot of Greg Kroah-Hartman.

Markus, you seem to have sent a nonsensical or otherwise pointless
review comment to a patch submission on a Linux kernel developer mailing
list.  I strongly suggest that you not do this anymore.  Please do not
bother developers who are actively working to produce patches and
features with comments that, in the end, are a waste of time.

Patch submitter, please ignore Markus's suggestion; you do not need to
follow it at all.  The person/bot/AI that sent it is being ignored by
almost all Linux kernel maintainers for having a persistent pattern of
behavior of producing distracting and pointless commentary, and
inability to adapt to feedback.  Please feel free to also ignore emails
from them.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH] media: atomisp: Use vmemdup_user() instead of open-coding
  2025-08-14 13:30 [PATCH] media: atomisp: Use vmemdup_user() instead of open-coding Qianfeng Rong
  2025-08-14 13:42 ` Markus Elfring
@ 2025-08-20 15:01 ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2025-08-20 15:01 UTC (permalink / raw)
  To: Qianfeng Rong
  Cc: Hans de Goede, Mauro Carvalho Chehab, Sakari Ailus,
	Andy Shevchenko, Greg Kroah-Hartman, Hans Verkuil, linux-media,
	linux-kernel, linux-staging

On Thu, Aug 14, 2025 at 09:30:29PM +0800, Qianfeng Rong wrote:
> Use vmemdup_user() to get a copy of the user buffer in
> atomisp_v4l2_framebuffer_to_css_frame().

> Compile-tested only.

Not sure if it worth to have in the commit message, but at least it doesn't
make it ugly. So, up to Hans.

...

> +	tmp_buf = vmemdup_user((void __user __force *)arg->base,
> +			       arg->fmt.sizeimage);

I know this is 85 characters on one line, but I would go as it makes a bit
better the readability in my opinion.

> +	if (IS_ERR(tmp_buf)) {
> +		ret = PTR_ERR(tmp_buf);
>  		goto err;
>  	}

...

>  err:
>  	if (ret && res)
>  		ia_css_frame_free(res);
> -	vfree(tmp_buf);
> +	if (!IS_ERR(tmp_buf))
> +		kvfree(tmp_buf);
>  	if (ret == 0)
>  		*result = res;
>  	return ret;

This is messy error handling, but it is definitely out of scope of the proposed
patch.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2025-08-20 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 13:30 [PATCH] media: atomisp: Use vmemdup_user() instead of open-coding Qianfeng Rong
2025-08-14 13:42 ` Markus Elfring
2025-08-14 13:58   ` Greg Kroah-Hartman
2025-08-20 15:01 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).