drm/i915: Fix kzalloc() smatch warnings in get_initial_plane_config()
Subsystems (2)
PATCH 1/1 drm/i915: Fix kzalloc() smatch warnings in get_initial_plane_config()
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.
--- drivers/gpu/drm/i915/intel_display.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +15 -6
@@ -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 ); +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 )
Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedQuoted 14 lines · Damien Lespiau
Smatch doesn't like:
struct drm_framebuffer *fb; fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);and warns with:
warn: struct type mismatch '
drm_framebuffervsintel_framebuffer'This implicit cast was correct as struct
intel_framebufferhas structdrm_framebufferas its first member, but in case someone want to reorder the fields for some reason, it's slightly safer to access the underlyingdrm_framebufferthroughintel_fb->base.
Quoted 5 lines
Also, having fewer static analysis warnings is a worthy goal.
Cc Dan Carpenter <[email protected]>Signed-off-by Damien Lespiau <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 72 lines
--- drivers/gpu/drm/i915/intel_display.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/intel_display.c +15
-6@@ -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 ); +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 )Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 28 lines · Damien Lespiau
Smatch doesn't like:
struct drm_framebuffer *fb; fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL);and warns with:
warn: struct type mismatch '
drm_framebuffervsintel_framebuffer'This implicit cast was correct as struct
intel_framebufferhas structdrm_framebufferas its first member, but in case someone want to reorder the fields for some reason, it's slightly safer to access the underlyingdrm_framebufferthroughintel_fb->base.Also, having fewer static analysis warnings is a worthy goal.
Cc Dan Carpenter <[email protected]>Signed-off-by Damien Lespiau <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-0
drivers/gpu/drm/i915/intel_display.c i9xx_get_initial_plane_config(struct intel_crtc *crtc, · line 6589
Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +2
-2@@ -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?
Quoted 55 lines
drivers/gpu/drm/i915/intel_display.c +13
-4+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 )Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx