drm/i915: Don't leak the DPT if drm_framebuffer_init() fails
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 15 Feb 2023 22:24:25 +0000 (00:24 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 16 Feb 2023 20:10:38 +0000 (22:10 +0200)
We are failing to free the already allocated DPT if the final
drm_framebuffer_init() fails. That would require idr_alloc() to
fail, so not very likely, but let's add the cleanup code anyway.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230215222426.26085-1-ville.syrjala@linux.intel.com
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
drivers/gpu/drm/i915/display/intel_fb.c

index 93d0e46..1ba052a 100644 (file)
@@ -2017,11 +2017,14 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
        ret = drm_framebuffer_init(&dev_priv->drm, fb, &intel_fb_funcs);
        if (ret) {
                drm_err(&dev_priv->drm, "framebuffer init failed %d\n", ret);
-               goto err;
+               goto err_free_dpt;
        }
 
        return 0;
 
+err_free_dpt:
+       if (intel_fb_uses_dpt(fb))
+               intel_dpt_destroy(intel_fb->dpt_vm);
 err:
        intel_frontbuffer_put(intel_fb->frontbuffer);
        return ret;