aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Paul <[email protected]>2019-06-19 14:19:47 -0400
committerSean Paul <[email protected]>2019-06-20 10:03:21 -0400
commit002c845be525939ee22899452fbe2b597d27b424 (patch)
tree76e033a4c13b48524f47b27733e581fc952ed73a
parent7d0ed30433aa88c94411b6c078a7985a6e7c889f (diff)
drm/self_refresh: Fix possible NULL deref in failure path
If state allocation fails, we still try to give back the reference on it. Also initialize ret in case the crtc is not enabled and we hit the eject button. Fixes: 1452c25b0e60 ("drm: Add helpers to kick off self refresh mode in drivers") Cc: Daniel Vetter <[email protected]> Cc: Jose Souza <[email protected]> Cc: Zain Wang <[email protected]> Cc: Tomasz Figa <[email protected]> Cc: Ville Syrjälä <[email protected]> Cc: Sam Ravnborg <[email protected]> Cc: Sean Paul <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Cc: [email protected] Reported-by: Dan Carpenter <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Sean Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
-rw-r--r--drivers/gpu/drm/drm_self_refresh_helper.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_self_refresh_helper.c b/drivers/gpu/drm/drm_self_refresh_helper.c
index e0d2ad1f070c..4b9424a8f1f1 100644
--- a/drivers/gpu/drm/drm_self_refresh_helper.c
+++ b/drivers/gpu/drm/drm_self_refresh_helper.c
@@ -69,14 +69,14 @@ static void drm_self_refresh_helper_entry_work(struct work_struct *work)
struct drm_connector *conn;
struct drm_connector_state *conn_state;
struct drm_crtc_state *crtc_state;
- int i, ret;
+ int i, ret = 0;
drm_modeset_acquire_init(&ctx, 0);
state = drm_atomic_state_alloc(dev);
if (!state) {
ret = -ENOMEM;
- goto out;
+ goto out_drop_locks;
}
retry:
@@ -116,6 +116,8 @@ out:
}
drm_atomic_state_put(state);
+
+out_drop_locks:
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
}