Commit 77050c3f authored by Jeykumar Sankaran's avatar Jeykumar Sankaran Committed by Sean Paul

drm/msm: Use labels for unwinding in the error path

This simplifies cleanup, to make sure nothing drops out in case of
error.

Changes in v3:
- None
Signed-off-by: default avatarJeykumar Sankaran <jsanka@codeaurora.org>
[seanpaul split out of dpu megapatch and renamed labels]
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent aaded2e3
...@@ -372,19 +372,16 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ...@@ -372,19 +372,16 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) { if (!priv) {
drm_dev_unref(ddev); ret = -ENOMEM;
return -ENOMEM; goto err_unref_drm_dev;
} }
ddev->dev_private = priv; ddev->dev_private = priv;
priv->dev = ddev; priv->dev = ddev;
ret = mdp5_mdss_init(ddev); ret = mdp5_mdss_init(ddev);
if (ret) { if (ret)
kfree(priv); goto err_free_priv;
drm_dev_unref(ddev);
return ret;
}
mdss = priv->mdss; mdss = priv->mdss;
...@@ -399,17 +396,12 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ...@@ -399,17 +396,12 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
/* Bind all our sub-components: */ /* Bind all our sub-components: */
ret = component_bind_all(dev, ddev); ret = component_bind_all(dev, ddev);
if (ret) { if (ret)
if (mdss && mdss->funcs) goto err_destroy_mdss;
mdss->funcs->destroy(ddev);
kfree(priv);
drm_dev_unref(ddev);
return ret;
}
ret = msm_init_vram(ddev); ret = msm_init_vram(ddev);
if (ret) if (ret)
goto fail; goto err_msm_uninit;
msm_gem_shrinker_init(ddev); msm_gem_shrinker_init(ddev);
...@@ -435,7 +427,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ...@@ -435,7 +427,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
*/ */
dev_err(dev, "failed to load kms\n"); dev_err(dev, "failed to load kms\n");
ret = PTR_ERR(kms); ret = PTR_ERR(kms);
goto fail; goto err_msm_uninit;
} }
/* Enable normalization of plane zpos */ /* Enable normalization of plane zpos */
...@@ -445,7 +437,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ...@@ -445,7 +437,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
ret = kms->funcs->hw_init(kms); ret = kms->funcs->hw_init(kms);
if (ret) { if (ret) {
dev_err(dev, "kms hw init failed: %d\n", ret); dev_err(dev, "kms hw init failed: %d\n", ret);
goto fail; goto err_msm_uninit;
} }
} }
...@@ -455,7 +447,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ...@@ -455,7 +447,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
ret = drm_vblank_init(ddev, priv->num_crtcs); ret = drm_vblank_init(ddev, priv->num_crtcs);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to initialize vblank\n"); dev_err(dev, "failed to initialize vblank\n");
goto fail; goto err_msm_uninit;
} }
if (kms) { if (kms) {
...@@ -464,13 +456,13 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ...@@ -464,13 +456,13 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to install IRQ handler\n"); dev_err(dev, "failed to install IRQ handler\n");
goto fail; goto err_msm_uninit;
} }
} }
ret = drm_dev_register(ddev, 0); ret = drm_dev_register(ddev, 0);
if (ret) if (ret)
goto fail; goto err_msm_uninit;
drm_mode_config_reset(ddev); drm_mode_config_reset(ddev);
...@@ -481,15 +473,23 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ...@@ -481,15 +473,23 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
ret = msm_debugfs_late_init(ddev); ret = msm_debugfs_late_init(ddev);
if (ret) if (ret)
goto fail; goto err_msm_uninit;
drm_kms_helper_poll_init(ddev); drm_kms_helper_poll_init(ddev);
return 0; return 0;
fail: err_msm_uninit:
msm_drm_uninit(dev); msm_drm_uninit(dev);
return ret; return ret;
err_destroy_mdss:
if (mdss && mdss->funcs)
mdss->funcs->destroy(ddev);
err_free_priv:
kfree(priv);
err_unref_drm_dev:
drm_dev_unref(ddev);
return ret;
} }
/* /*
......
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