]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/atomic: Don't pollute crtc_state->mode_blob with error pointers
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 9 Feb 2022 09:19:27 +0000 (11:19 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 16 Feb 2022 10:32:07 +0000 (12:32 +0200)
Make sure we don't assign an error pointer to crtc_state->mode_blob
as that will break all kinds of places that assume either NULL or a
valid pointer (eg. drm_property_blob_put()).

Cc: stable@vger.kernel.org
Reported-by: fuyufan <fuyufan@huawei.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220209091928.14766-1-ville.syrjala@linux.intel.com
Acked-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/drm_atomic_uapi.c

index 9781722519c3b1f7082ad46505c916b9ab8e7c14..54d62fdb4ef9fbaa4c4bf7f55ce46c2f9577d819 100644 (file)
@@ -76,15 +76,17 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
        state->mode_blob = NULL;
 
        if (mode) {
+               struct drm_property_blob *blob;
+
                drm_mode_convert_to_umode(&umode, mode);
-               state->mode_blob =
-                       drm_property_create_blob(state->crtc->dev,
-                                                sizeof(umode),
-                                                &umode);
-               if (IS_ERR(state->mode_blob))
-                       return PTR_ERR(state->mode_blob);
+               blob = drm_property_create_blob(crtc->dev,
+                                               sizeof(umode), &umode);
+               if (IS_ERR(blob))
+                       return PTR_ERR(blob);
 
                drm_mode_copy(&state->mode, mode);
+
+               state->mode_blob = blob;
                state->enable = true;
                drm_dbg_atomic(crtc->dev,
                               "Set [MODE:%s] for [CRTC:%d:%s] state %p\n",