History

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.

Sean Paul committed 7 years ago

Commit 002c8451 parent 7d0ed301 file · +4 −2Browse files

Unified · Split

drivers/gpu/drm/drm_self_refresh_helper.c+4−2
@@ -69,14 +69,14 @@ static void drm_self_refresh_helper_entry_work(struct work_struct *work) · 68 unmodified lines
69 struct drm_connector *conn;69 struct drm_connector *conn;
70 struct drm_connector_state *conn_state;70 struct drm_connector_state *conn_state;
71 struct drm_crtc_state *crtc_state;71 struct drm_crtc_state *crtc_state;
72 int i, ret;72 int i, ret = 0;
73 73
74 drm_modeset_acquire_init(&ctx, 0);74 drm_modeset_acquire_init(&ctx, 0);
75 75
76 state = drm_atomic_state_alloc(dev);76 state = drm_atomic_state_alloc(dev);
77 if (!state) {77 if (!state) {
78 ret = -ENOMEM;78 ret = -ENOMEM;
79 goto out;79 goto out_drop_locks;
80 }80 }
81 81
82retry:82retry:
@@ -116,6 +116,8 @@ out: · 33 unmodified lines
116 }116 }
117 117
118 drm_atomic_state_put(state);118 drm_atomic_state_put(state);
119
120out_drop_locks:
119 drm_modeset_drop_locks(&ctx);121 drm_modeset_drop_locks(&ctx);
120 drm_modeset_acquire_fini(&ctx);122 drm_modeset_acquire_fini(&ctx);
121}123}