Skip to contentSkip to conversation

i915: don't call drm_atomic_state_put on invalid pointer

PATCH Applied Arnd Bergmann 4 participants 4 messages Oct 18, 2016 – Oct 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i915: don't call drm_atomic_state_put on invalid pointer

The introduction of reference counting on the state structures caused sanitize_watermarks() in i915 to break in the error handling case, as pointed out by gcc -Wmaybe-uninitialized

drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This changes the function back to only drop the reference count when it was successfully allocated first.

Fixes 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
index 6d168685bbda..6a26da143aa6 100644
@@ -16314,7 +16314,7 @@ static void sanitize_watermarks(struct drm_device *dev)
 		 * BIOS-programmed watermarks untouched and hope for the best.
 		 */
 		WARN(true, "Could not determine valid watermarks for inherited state\n");
-		goto fail;
+		goto put_state;
 	}
 
 	/* Write calculated watermark values back */
@@ -16325,8 +16325,9 @@ static void sanitize_watermarks(struct drm_device *dev)
 		dev_priv->display.optimize_watermarks(cs);
 	}
 
-fail:
+put_state:
 	drm_atomic_state_put(state);
+fail:
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 }
Signature · 1 line
2.9.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Arnd Bergmann

The introduction of reference counting on the state structures caused sanitize_watermarks() in i915 to break in the error handling case, as pointed out by gcc -Wmaybe-uninitialized

drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 7 lines

This changes the function back to only drop the reference count when it was successfully allocated first.

Fixes 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>
Quoted 30 lines
---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
index 6d168685bbda..6a26da143aa6 100644
@@ -16314,7 +16314,7 @@ static void sanitize_watermarks(struct drm_device *dev)
 		 * BIOS-programmed watermarks untouched and hope for the best.
 		 */
 		WARN(true, "Could not determine valid watermarks for inherited state\n");
-		goto fail;
+		goto put_state;
 	}
 
 	/* Write calculated watermark values back */
@@ -16325,8 +16325,9 @@ static void sanitize_watermarks(struct drm_device *dev)
 		dev_priv->display.optimize_watermarks(cs);
 	}
 
-fail:
+put_state:
 	drm_atomic_state_put(state);
+fail:
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 }
Signature · 1 line
2.9.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

The introduction of reference counting on the state structures caused sanitize_watermarks() in i915 to break in the error handling case, as pointed out by gcc -Wmaybe-uninitialized

drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 7 lines

This changes the function back to only drop the reference count when it was successfully allocated first.

Fixes 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>

Yup, missed that it jumps to fail before allocating state.

Function still looks a bit odd, but nvm

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 16 lines · Chris Wilson
Quoted 7 lines · Arnd Bergmann

The introduction of reference counting on the state structures caused sanitize_watermarks() in i915 to break in the error handling case, as pointed out by gcc -Wmaybe-uninitialized

drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 7 lines

This changes the function back to only drop the reference count when it was successfully allocated first.

Fixes 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>
Quoted 4 lines

Yup, missed that it jumps to fail before allocating state.

Function still looks a bit odd, but nvm

Applied to drm-misc, thanks for the patch&review.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel