Noticed a bundle of memory leaks after radeon_driver_load_kms fails.
After dev->driver->load failes, drm_get_dev doesn't free memories
allocated from drm_fill_in_dev.

Signed-off-by: Xiaotian Feng <df...@redhat.com>
---
 drivers/gpu/drm/drm_stub.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index fe7f5c4..db9057c 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -448,23 +448,23 @@ int drm_get_dev(struct pci_dev *pdev, const struct 
pci_device_id *ent,
                pci_set_drvdata(pdev, dev);
                ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
                if (ret)
-                       goto err_g2;
+                       goto err_g3;
        }
 
        if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
-               goto err_g3;
+               goto err_g4;
 
        if (dev->driver->load) {
                ret = dev->driver->load(dev, ent->driver_data);
                if (ret)
-                       goto err_g4;
+                       goto err_g5;
        }
 
         /* setup the grouping for the legacy output */
        if (drm_core_check_feature(dev, DRIVER_MODESET)) {
                ret = drm_mode_group_init_legacy_group(dev, 
&dev->primary->mode_group);
                if (ret)
-                       goto err_g4;
+                       goto err_g5;
        }
 
        list_add_tail(&dev->driver_item, &driver->device_list);
@@ -475,11 +475,13 @@ int drm_get_dev(struct pci_dev *pdev, const struct 
pci_device_id *ent,
 
        return 0;
 
-err_g4:
+err_g5:
        drm_put_minor(&dev->primary);
-err_g3:
+err_g4:
        if (drm_core_check_feature(dev, DRIVER_MODESET))
                drm_put_minor(&dev->control);
+err_g3:
+       drm_cleanup_dev(dev);
 err_g2:
        pci_disable_device(pdev);
 err_g1:
-- 
1.6.2.5


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to