public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/i915: Fix the return value of pipe crc read function.
Date: Wed, 3 Aug 2016 09:48:45 +0200	[thread overview]
Message-ID: <20160803074845.GG6232@phenom.ffwll.local> (raw)
In-Reply-To: <1470199327-5833-2-git-send-email-rodrigo.vivi@intel.com>

On Tue, Aug 02, 2016 at 09:42:07PM -0700, Rodrigo Vivi wrote:
> A read(fd, buf, len) function should return the number
> of bytes read. In our case we need to return the
> number of bytes we copy to user, instead of returning
> the number of bytes we read internally.
> 
> It was really strange when I saw i-g-t test case using
> len '54' but getting '56' as return. First thought was
> how do we read more than we asked? But also I checked
> and there was really only 54. Until I realized it
> was all our fault. EFAULT!
> 
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 7052c47..b7b8d79 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -3659,7 +3659,7 @@ i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
>  
>  	spin_unlock_irq(&pipe_crc->lock);
>  
> -	return bytes_read;
> +	return PIPE_CRC_LINE_LEN;

This will no loose entries if you have more than 1 crc ready to be read. I
think better to WARN_ON if snprintf doesn't give us the expected length,
and then correct bytes_read to match.
-Daniel

>  }
>  
>  static const struct file_operations i915_pipe_crc_fops = {
> -- 
> 2.5.5
> 
> _______________________________________________
> 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
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-08-03  7:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03  4:42 [PATCH 1/2] drm/i915: Fix copy_to_user usage for pipe_crc Rodrigo Vivi
2016-08-03  4:42 ` [PATCH 2/2] drm/i915: Fix the return value of pipe crc read function Rodrigo Vivi
2016-08-03  7:31   ` Ville Syrjälä
2016-08-03 14:44     ` Vivi, Rodrigo
2016-08-05 21:50       ` Pandiyan, Dhinakaran
2016-08-03  7:48   ` Daniel Vetter [this message]
2016-08-03  6:49 ` ✗ Ro.CI.BAT: failure for series starting with [1/2] drm/i915: Fix copy_to_user usage for pipe_crc Patchwork
2016-08-03  7:29 ` [PATCH 1/2] " Ville Syrjälä
2016-08-03  7:44 ` Daniel Vetter

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=20160803074845.GG6232@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@intel.com \
    /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