From: Daniel Vetter <daniel@ffwll.ch>
To: Geliang Tang <geliangtang@gmail.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
David Airlie <airlied@linux.ie>,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915: use memdup_user_nul
Date: Mon, 8 May 2017 09:29:00 +0200 [thread overview]
Message-ID: <20170508072900.dr6gsx7uxrd4tmp6@phenom.ffwll.local> (raw)
In-Reply-To: <6baf3aa45d0b5e0fd016b508bac905ebf8443aac.1493779294.git.geliangtang@gmail.com>
On Sat, May 06, 2017 at 11:40:17PM +0800, Geliang Tang wrote:
> Use memdup_user_nul() helper instead of open-coding to simplify the
> code.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Thx for the patch, applied to drm-intel.git.
-Daniel
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 13 +++----------
> drivers/gpu/drm/i915/intel_pipe_crc.c | 13 +++----------
> 2 files changed, 6 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index d689e51..e56b636 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -3704,16 +3704,10 @@ static ssize_t i915_displayport_test_active_write(struct file *file,
> if (len == 0)
> return 0;
>
> - input_buffer = kmalloc(len + 1, GFP_KERNEL);
> - if (!input_buffer)
> - return -ENOMEM;
> + input_buffer = memdup_user_nul(ubuf, len);
> + if (IS_ERR(input_buffer))
> + return PTR_ERR(input_buffer);
>
> - if (copy_from_user(input_buffer, ubuf, len)) {
> - status = -EFAULT;
> - goto out;
> - }
> -
> - input_buffer[len] = '\0';
> DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
>
> drm_connector_list_iter_begin(dev, &conn_iter);
> @@ -3739,7 +3733,6 @@ static ssize_t i915_displayport_test_active_write(struct file *file,
> }
> }
> drm_connector_list_iter_end(&conn_iter);
> -out:
> kfree(input_buffer);
> if (status < 0)
> return status;
> diff --git a/drivers/gpu/drm/i915/intel_pipe_crc.c b/drivers/gpu/drm/i915/intel_pipe_crc.c
> index 206ee4f..813dd3c 100644
> --- a/drivers/gpu/drm/i915/intel_pipe_crc.c
> +++ b/drivers/gpu/drm/i915/intel_pipe_crc.c
> @@ -842,19 +842,12 @@ static ssize_t display_crc_ctl_write(struct file *file, const char __user *ubuf,
> return -E2BIG;
> }
>
> - tmpbuf = kmalloc(len + 1, GFP_KERNEL);
> - if (!tmpbuf)
> - return -ENOMEM;
> -
> - if (copy_from_user(tmpbuf, ubuf, len)) {
> - ret = -EFAULT;
> - goto out;
> - }
> - tmpbuf[len] = '\0';
> + tmpbuf = memdup_user_nul(ubuf, len);
> + if (IS_ERR(tmpbuf))
> + return PTR_ERR(tmpbuf);
>
> ret = display_crc_ctl_parse(dev_priv, tmpbuf, len);
>
> -out:
> kfree(tmpbuf);
> if (ret < 0)
> return ret;
> --
> 2.9.3
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
prev parent reply other threads:[~2017-05-08 7:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-06 15:40 Geliang Tang
2017-05-06 15:40 ` [PATCH] ima: " Geliang Tang
2017-05-08 15:44 ` Mimi Zohar
2017-05-06 15:40 ` [PATCH] platform/x86: toshiba_acpi: " Geliang Tang
2017-05-07 11:42 ` Andy Shevchenko
2017-05-06 15:40 ` [PATCH] sparc: use memdup_user_nul in sun4m LED driver Geliang Tang
2017-05-09 19:16 ` David Miller
2017-05-08 7:29 ` Daniel Vetter [this message]
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=20170508072900.dr6gsx7uxrd4tmp6@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@linux.ie \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=geliangtang@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
/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®