[PATCH] [drm/sti] sti_compositor: Add error handlingin sti_compositor_bind

From: Haoran Liu
Date: Wed Nov 29 2023 - 04:49:18 EST


Previously, the function sti_compositor_bind did not properly
handle potential failure scenarios of drm_vblank_init, which could
lead to unexpected behavior. This update adds a check for the
return value of drm_vblank_init.

Signed-off-by: Haoran Liu <liuhaoran14@xxxxxxx>
---
drivers/gpu/drm/sti/sti_compositor.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sti/sti_compositor.c b/drivers/gpu/drm/sti/sti_compositor.c
index 33487a1fed8f..beddbd1c48eb 100644
--- a/drivers/gpu/drm/sti/sti_compositor.c
+++ b/drivers/gpu/drm/sti/sti_compositor.c
@@ -69,6 +69,7 @@ static int sti_compositor_bind(struct device *dev,
struct drm_plane *primary = NULL;
struct sti_compositor_subdev_descriptor *desc = compo->data.subdev_desc;
unsigned int array_size = compo->data.nb_subdev;
+ int ret;

dev_priv->compo = compo;

@@ -145,7 +146,11 @@ static int sti_compositor_bind(struct device *dev,
}
}

- drm_vblank_init(drm_dev, crtc_id);
+ ret = drm_vblank_init(drm_dev, crtc_id);
+ if (ret) {
+ DRM_ERROR("Failed to initialize vblank\n");
+ return ret;
+ }

return 0;
}
--
2.17.1