Skip to contentSkip to conversation

drm: fix uninitialized acquire_ctx fields

PATCH In review Rob Clark 2 participants 2 messages Jun 7, 2014

Subsystems (2)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm: fix uninitialized acquire_ctx fields

The acquire ctx will typically be declared on the stack, which means we could have garbage values for any uninitialized field. In this case, it was triggering WARN_ON()s because 'contended' had garbage value.

Go ahead and use memset() to be more future-proof.

---
 drivers/gpu/drm/drm_modeset_lock.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_modeset_lock.c +1 -0
index 7c2497d..4e8b244 100644
@@ -64,6 +64,7 @@
 void drm_modeset_acquire_init(struct drm_modeset_acquire_ctx *ctx,
 		uint32_t flags)
 {
+	memset(ctx, 0, sizeof(ctx));
 	ww_acquire_init(&ctx->ww_ctx, &crtc_ww_class);
 	INIT_LIST_HEAD(&ctx->locked);
 }
Signature · 6 lines
1.9.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 17 lines · Rob Clark

The acquire ctx will typically be declared on the stack, which means we could have garbage values for any uninitialized field. In this case, it was triggering WARN_ON()s because 'contended' had garbage value.

Go ahead and use memset() to be more future-proof.

---
 drivers/gpu/drm/drm_modeset_lock.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_modeset_lock.c +0 -0
index 7c2497d..4e8b244 100644

drivers/gpu/drm/drm_modeset_lock.c line 67

Quoted 4 lines
drivers/gpu/drm/drm_modeset_lock.c +1 -0
@@ -64,6 +64,7 @@
 void drm_modeset_acquire_init(struct drm_modeset_acquire_ctx *ctx,
 		uint32_t flags)
 {
+	memset(ctx, 0, sizeof(ctx));
                              ^^^

*ctx

with that fixed:

Quoted 5 lines
drivers/gpu/drm/drm_modeset_lock.c +0 -0
 	ww_acquire_init(&ctx->ww_ctx, &crtc_ww_class);
 	INIT_LIST_HEAD(&ctx->locked);
 }
Signature · 1 line
1.9.3
Signature · 2 lines
Ville Syrjälä
Intel OTC