Commit a695949b authored by Yao Zi's avatar Yao Zi Committed by Neil Armstrong

drm/meson: fix canvas release in bind function

Allocated canvases may not be released on the error exit path of
meson_drv_bind_master(), leading to resource leaking. Rewrite exit path
to release canvases on error.

Fixes: 2bf6b5b0 ("drm/meson: exclusively use the canvas provider module")
Signed-off-by: default avatarYao Zi <ziyao@disroot.org>
Reviewed-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20240703155826.10385-2-ziyao@disroot.orgSigned-off-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240703155826.10385-2-ziyao@disroot.org
parent 91f9f4a3
...@@ -250,29 +250,20 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) ...@@ -250,29 +250,20 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
if (ret) if (ret)
goto free_drm; goto free_drm;
ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_0); ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_0);
if (ret) { if (ret)
meson_canvas_free(priv->canvas, priv->canvas_id_osd1); goto free_canvas_osd1;
goto free_drm;
}
ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_1); ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_1);
if (ret) { if (ret)
meson_canvas_free(priv->canvas, priv->canvas_id_osd1); goto free_canvas_vd1_0;
meson_canvas_free(priv->canvas, priv->canvas_id_vd1_0);
goto free_drm;
}
ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_2); ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_vd1_2);
if (ret) { if (ret)
meson_canvas_free(priv->canvas, priv->canvas_id_osd1); goto free_canvas_vd1_1;
meson_canvas_free(priv->canvas, priv->canvas_id_vd1_0);
meson_canvas_free(priv->canvas, priv->canvas_id_vd1_1);
goto free_drm;
}
priv->vsync_irq = platform_get_irq(pdev, 0); priv->vsync_irq = platform_get_irq(pdev, 0);
ret = drm_vblank_init(drm, 1); ret = drm_vblank_init(drm, 1);
if (ret) if (ret)
goto free_drm; goto free_canvas_vd1_2;
/* Assign limits per soc revision/package */ /* Assign limits per soc revision/package */
for (i = 0 ; i < ARRAY_SIZE(meson_drm_soc_attrs) ; ++i) { for (i = 0 ; i < ARRAY_SIZE(meson_drm_soc_attrs) ; ++i) {
...@@ -288,11 +279,11 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) ...@@ -288,11 +279,11 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
*/ */
ret = drm_aperture_remove_framebuffers(&meson_driver); ret = drm_aperture_remove_framebuffers(&meson_driver);
if (ret) if (ret)
goto free_drm; goto free_canvas_vd1_2;
ret = drmm_mode_config_init(drm); ret = drmm_mode_config_init(drm);
if (ret) if (ret)
goto free_drm; goto free_canvas_vd1_2;
drm->mode_config.max_width = 3840; drm->mode_config.max_width = 3840;
drm->mode_config.max_height = 2160; drm->mode_config.max_height = 2160;
drm->mode_config.funcs = &meson_mode_config_funcs; drm->mode_config.funcs = &meson_mode_config_funcs;
...@@ -307,7 +298,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) ...@@ -307,7 +298,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
if (priv->afbcd.ops) { if (priv->afbcd.ops) {
ret = priv->afbcd.ops->init(priv); ret = priv->afbcd.ops->init(priv);
if (ret) if (ret)
goto free_drm; goto free_canvas_vd1_2;
} }
/* Encoder Initialization */ /* Encoder Initialization */
...@@ -371,6 +362,14 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) ...@@ -371,6 +362,14 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
exit_afbcd: exit_afbcd:
if (priv->afbcd.ops) if (priv->afbcd.ops)
priv->afbcd.ops->exit(priv); priv->afbcd.ops->exit(priv);
free_canvas_vd1_2:
meson_canvas_free(priv->canvas, priv->canvas_id_vd1_2);
free_canvas_vd1_1:
meson_canvas_free(priv->canvas, priv->canvas_id_vd1_1);
free_canvas_vd1_0:
meson_canvas_free(priv->canvas, priv->canvas_id_vd1_0);
free_canvas_osd1:
meson_canvas_free(priv->canvas, priv->canvas_id_osd1);
free_drm: free_drm:
drm_dev_put(drm); drm_dev_put(drm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment