This patch adds error-handling for the drm_connector_init() and drm_connector_attach_encoder inside the mdp4_lvds_connector_init(). Signed-off-by: liuhaoran <liuhaoran14@xxxxxxx> --- .../gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c index 7444b75c4215..62eb363ba90f 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c @@ -96,6 +96,7 @@ struct drm_connector *mdp4_lvds_connector_init(struct drm_device *dev, { struct drm_connector *connector = NULL; struct mdp4_lvds_connector *mdp4_lvds_connector; + int ret; mdp4_lvds_connector = kzalloc(sizeof(*mdp4_lvds_connector), GFP_KERNEL); if (!mdp4_lvds_connector) @@ -106,8 +107,12 @@ struct drm_connector *mdp4_lvds_connector_init(struct drm_device *dev, connector = &mdp4_lvds_connector->base; - drm_connector_init(dev, connector, &mdp4_lvds_connector_funcs, - DRM_MODE_CONNECTOR_LVDS); + ret = drm_connector_init(dev, connector, &mdp4_lvds_connector_funcs, + DRM_MODE_CONNECTOR_LVDS); + + if (ret) + return ret; + drm_connector_helper_add(connector, &mdp4_lvds_connector_helper_funcs); connector->polled = 0; @@ -115,7 +120,10 @@ struct drm_connector *mdp4_lvds_connector_init(struct drm_device *dev, connector->interlace_allowed = 0; connector->doublescan_allowed = 0; - drm_connector_attach_encoder(connector, encoder); + ret = drm_connector_attach_encoder(connector, encoder); + + if (ret) + return ret; return connector; } -- 2.17.1