A call to drm_encoder_init() can fail. If the error code is not checked
this may lead to drm_encoder_cleanup() being called on an uninitialized
drm_encoder.
This patch addresses this by adding the proper return value check to the
drm_encoder_init() function call.

Signed-off-by: Diogo Silva <[email protected]>
---
 drivers/gpu/drm/xlnx/zynqmp_kms.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_kms.c 
b/drivers/gpu/drm/xlnx/zynqmp_kms.c
index 698ac692abce..1d194c2824e3 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_kms.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_kms.c
@@ -439,8 +439,13 @@ static int zynqmp_dpsub_kms_init(struct zynqmp_dpsub 
*dpsub)
 
        /* Create the encoder and attach the bridge. */
        encoder->possible_crtcs |= drm_crtc_mask(&dpsub->drm->crtc);
-       drm_encoder_init(&dpsub->drm->dev, encoder, &zynqmp_dpsub_encoder_funcs,
-                        DRM_MODE_ENCODER_NONE, NULL);
+       ret = drm_encoder_init(&dpsub->drm->dev, encoder,
+                              &zynqmp_dpsub_encoder_funcs,
+                              DRM_MODE_ENCODER_NONE, NULL);
+       if (ret) {
+               dev_err(dpsub->dev, "failed to initialize encoder\n");
+               return ret;
+       }
 
        ret = drm_bridge_attach(encoder, dpsub->bridge, NULL,
                                DRM_BRIDGE_ATTACH_NO_CONNECTOR);

-- 
2.51.2

Reply via email to