All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Damien Lespiau <damien.lespiau@intel.com>
Cc: intel-gfx@lists.freedesktop.org, kbuild@01.org,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH] drm/i915: Fix kzalloc() smatch warnings in get_initial_plane_config()
Date: Wed, 21 Jan 2015 15:57:20 +0200	[thread overview]
Message-ID: <20150121135720.GJ19354@intel.com> (raw)
In-Reply-To: <1421848254-586-1-git-send-email-damien.lespiau@intel.com>

On Wed, Jan 21, 2015 at 01:50:54PM +0000, Damien Lespiau wrote:
> Smatch doesn't like:
> 
>   struct drm_framebuffer *fb;
>   fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);
> 
> and warns with:
> 
>   warn: struct type mismatch 'drm_framebuffer vs intel_framebuffer'
> 
> This implicit cast was correct as struct intel_framebuffer has struct
> drm_framebuffer as its first member, but in case someone want to reorder
> the fields for some reason, it's slightly safer to access the underlying
> drm_framebuffer through intel_fb->base.
> 
> Also, having fewer static analysis warnings is a worthy goal.
> 
> Cc: kbuild@01.org
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 65fce56..01dc80b 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -6584,13 +6584,16 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
>  	int fourcc, pixel_format;
>  	int aligned_height;
>  	struct drm_framebuffer *fb;
> +	struct intel_framebuffer *intel_fb;
>  
> -	fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);
> -	if (!fb) {
> +	intel_fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);

sizeof(*intel_fb) while at it?

> +	if (!intel_fb) {
>  		DRM_DEBUG_KMS("failed to alloc fb\n");
>  		return;
>  	}
>  
> +	fb = &intel_fb->base;
> +
>  	val = I915_READ(DSPCNTR(plane));
>  
>  	if (INTEL_INFO(dev)->gen >= 4)
> @@ -7613,13 +7616,16 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
>  	int fourcc, pixel_format;
>  	int aligned_height;
>  	struct drm_framebuffer *fb;
> +	struct intel_framebuffer *intel_fb;
>  
> -	fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);
> -	if (!fb) {
> +	intel_fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);
> +	if (!intel_fb) {
>  		DRM_DEBUG_KMS("failed to alloc fb\n");
>  		return;
>  	}
>  
> +	fb = &intel_fb->base;
> +
>  	val = I915_READ(PLANE_CTL(pipe, 0));
>  	if (val & PLANE_CTL_TILED_MASK)
>  		plane_config->tiling = I915_TILING_X;
> @@ -7706,13 +7712,16 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
>  	int fourcc, pixel_format;
>  	int aligned_height;
>  	struct drm_framebuffer *fb;
> +	struct intel_framebuffer *intel_fb;
>  
> -	fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);
> -	if (!fb) {
> +	intel_fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);
> +	if (!intel_fb) {
>  		DRM_DEBUG_KMS("failed to alloc fb\n");
>  		return;
>  	}
>  
> +	fb = &intel_fb->base;
> +
>  	val = I915_READ(DSPCNTR(pipe));
>  
>  	if (INTEL_INFO(dev)->gen >= 4)
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

      parent reply	other threads:[~2015-01-21 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 13:50 [PATCH] drm/i915: Fix kzalloc() smatch warnings in get_initial_plane_config() Damien Lespiau
2015-01-21 13:54 ` Daniel Vetter
2015-01-21 13:57 ` Ville Syrjälä [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=20150121135720.GJ19354@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=damien.lespiau@intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=kbuild@01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.