mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Binns <Frank.Binns@imgtec.com>
To: "tzimmermann@suse.de" <tzimmermann@suse.de>,
	Matt Coster <Matt.Coster@imgtec.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"ruanjinjie@huawei.com" <ruanjinjie@huawei.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"mripard@kernel.org" <mripard@kernel.org>
Subject: Re: [PATCH -next v2] drm/imagination: Use memdup_user() helper
Date: Mon, 2 Sep 2024 07:59:53 +0000	[thread overview]
Message-ID: <2937c8c073bab2694b8f55bec62898b02ef7a07e.camel@imgtec.com> (raw)
In-Reply-To: <20240902023300.1214753-1-ruanjinjie@huawei.com>

On Mon, 2024-09-02 at 10:33 +0800, Jinjie Ruan wrote:
> Switching to memdup_user(), which combines kmalloc() and copy_from_user(),
> and it can simplfy code.
> 

Reviewed-by: Frank Binns <frank.binns@imgtec.com>

> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> v2:
> - Add suggested-by.
> - Simplify the code.
> ---
>  drivers/gpu/drm/imagination/pvr_context.c | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/imagination/pvr_context.c b/drivers/gpu/drm/imagination/pvr_context.c
> index eded5e955cc0..98327f9bbd9c 100644
> --- a/drivers/gpu/drm/imagination/pvr_context.c
> +++ b/drivers/gpu/drm/imagination/pvr_context.c
> @@ -69,24 +69,12 @@ process_static_context_state(struct pvr_device *pvr_dev, const struct pvr_stream
>  	void *stream;
>  	int err;
>  
> -	stream = kzalloc(stream_size, GFP_KERNEL);
> -	if (!stream)
> -		return -ENOMEM;
> -
> -	if (copy_from_user(stream, u64_to_user_ptr(stream_user_ptr), stream_size)) {
> -		err = -EFAULT;
> -		goto err_free;
> -	}
> +	stream = memdup_user(u64_to_user_ptr(stream_user_ptr), stream_size);
> +	if (IS_ERR(stream))
> +		return PTR_ERR(stream);
>  
>  	err = pvr_stream_process(pvr_dev, cmd_defs, stream, stream_size, dest);
> -	if (err)
> -		goto err_free;
> -
> -	kfree(stream);
> -
> -	return 0;
>  
> -err_free:
>  	kfree(stream);
>  
>  	return err;

  reply	other threads:[~2024-09-02  8:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02  2:33 Jinjie Ruan
2024-09-02  7:59 ` Frank Binns [this message]
2024-09-02  9:21 ` Matt Coster
2024-09-02 16:09   ` Markus Elfring
2024-09-03  9:12     ` Matt Coster
2024-09-03  9:40       ` [v2] " Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2937c8c073bab2694b8f55bec62898b02ef7a07e.camel@imgtec.com \
    --to=frank.binns@imgtec.com \
    --cc=Matt.Coster@imgtec.com \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=ruanjinjie@huawei.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®