Skip to contentSkip to conversation

drm/cirrus: fix leaky driver load error handling

PATCH In review Zach Reizner 2 participants 2 messages Dec 1, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/cirrus: fix leaky driver load error handling

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.

---
 drivers/gpu/drm/cirrus/cirrus_main.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/cirrus/cirrus_main.c +9 -4
index 99c1983..ab7cb54 100644
@@ -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;
 }
 
Signature · 6 lines
2.2.0.rc0.207.ga3a616c

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Zach Reizner

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.

Thanks for updating this, looks good to me.

Quoted 37 lines
---
 drivers/gpu/drm/cirrus/cirrus_main.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/cirrus/cirrus_main.c +9 -5
index 99c1983..ab7cb54 100644
@@ -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;
 }
 
--
Quoted 2 lines

2.2.0.rc0.207.ga3a616c

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel