Skip to contentSkip to conversation

drm: fix uninitialized acquire_ctx fields (v2)

PATCH In review Rob Clark 3 participants 3 messages Jun 7, 2014 – Jun 23, 2014

Subsystems (2)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm: fix uninitialized acquire_ctx fields (v2)

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.

v2: now with extra brown paper bag

---
 drivers/gpu/drm/drm_modeset_lock.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_modeset_lock.c +1 -0
index 7c2497d..0dc57d5 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 10 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.

v2: now with extra brown paper bag

I thought I already gave these. Well here they are again:

Quoted 18 lines
---
 drivers/gpu/drm/drm_modeset_lock.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_modeset_lock.c +1 -0
index 7c2497d..0dc57d5 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 · 1 line
1.9.3
Signature · 2 lines
Ville Syrjälä
Intel OTC
#2 lore raw
Quoted 7 lines · Ville Syrjälä
Quoted 6 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.

Quoted 8 lines
Quoted 4 lines

v2: now with extra brown paper bag

I thought I already gave these. Well here they are again:

https://bugzilla.kernel.org/show_bug.cgi?id=78401

Quoted 27 lines
Quoted 19 lines
---
 drivers/gpu/drm/drm_modeset_lock.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_modeset_lock.c +1 -0
index 7c2497d..0dc57d5 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 · 1 line
1.9.3
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel