diff mbox

[v2] drm/cirrus: fix leaky driver load error handling

Message ID 1417472151-3559-1-git-send-email-zachr@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zach Reizner Dec. 1, 2014, 10:15 p.m. UTC
Before this patch, cirrus_mm_init could have failed while
cirrus_modeset_init succeeded and the driver would have reported overall
success on load. This patch causes cirrus_driver_load to return on the
first error encountered.

Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: Zach Reizner <zachr@google.com>
---
 drivers/gpu/drm/cirrus/cirrus_main.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Sean Paul Dec. 1, 2014, 10:18 p.m. UTC | #1
On Mon, Dec 1, 2014 at 2:15 PM, Zach Reizner <zachr@google.com> wrote:
> Before this patch, cirrus_mm_init could have failed while
> cirrus_modeset_init succeeded and the driver would have reported overall
> success on load. This patch causes cirrus_driver_load to return on the
> first error encountered.
>
> Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>


Thanks for updating this, looks good to me.

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> Signed-off-by: Zach Reizner <zachr@google.com>
> ---
>  drivers/gpu/drm/cirrus/cirrus_main.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c
> index 99c1983..ab7cb54 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_main.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_main.c
> @@ -179,17 +179,22 @@ int cirrus_driver_load(struct drm_device *dev, unsigned long flags)
>         }
>
>         r = cirrus_mm_init(cdev);
> -       if (r)
> +       if (r) {
>                 dev_err(&dev->pdev->dev, "fatal err on mm init\n");
> +               goto out;
> +       }
>
>         r = cirrus_modeset_init(cdev);
> -       if (r)
> +       if (r) {
>                 dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r);
> +               goto out;
> +       }
>
>         dev->mode_config.funcs = (void *)&cirrus_mode_funcs;
> +
> +       return 0;
>  out:
> -       if (r)
> -               cirrus_driver_unload(dev);
> +       cirrus_driver_unload(dev);
>         return r;
>  }
>
> --
> 2.2.0.rc0.207.ga3a616c
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c
index 99c1983..ab7cb54 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -179,17 +179,22 @@  int cirrus_driver_load(struct drm_device *dev, unsigned long flags)
 	}
 
 	r = cirrus_mm_init(cdev);
-	if (r)
+	if (r) {
 		dev_err(&dev->pdev->dev, "fatal err on mm init\n");
+		goto out;
+	}
 
 	r = cirrus_modeset_init(cdev);
-	if (r)
+	if (r) {
 		dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r);
+		goto out;
+	}
 
 	dev->mode_config.funcs = (void *)&cirrus_mode_funcs;
+
+	return 0;
 out:
-	if (r)
-		cirrus_driver_unload(dev);
+	cirrus_driver_unload(dev);
 	return r;
 }