In drm_fill_in_dev, drm_ht_create/drm_agp_init/drm_gem_init all allocate memories. but in the fail path, those memory is not freed, then memory leaks is resulted.
Signed-off-by: Xiaotian Feng <df...@redhat.com> --- drivers/gpu/drm/drm_stub.c | 25 ++++++++++++++++++++----- 1 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 55bb8a8..8ac1ddb 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -259,7 +259,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, && (dev->agp == NULL)) { DRM_ERROR("Cannot initialize the agpgart module.\n"); retcode = -EINVAL; - goto error_out_unreg; + goto error_agp; } if (drm_core_has_MTRR(dev)) { if (dev->agp) @@ -274,7 +274,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, retcode = drm_ctxbitmap_init(dev); if (retcode) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); - goto error_out_unreg; + goto error_ctxbitmap; } if (driver->driver_features & DRIVER_GEM) { @@ -282,14 +282,29 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, if (retcode) { DRM_ERROR("Cannot initialize graphics execution " "manager (GEM)\n"); - goto error_out_unreg; + goto error_gem; } } return 0; - error_out_unreg: - drm_lastclose(dev); +error_gem: + drm_ctxbitmap_cleanup(dev); +error_ctxbitmap: + if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && + dev->agp && dev->agp->agp_mtrr >= 0) { + int retval; + retval = mtrr_del(dev->agp->agp_mtrr, + dev->agp->agp_info.aper_base, + dev->agp->agp_info.aper_size * 1024 * 1024); + DRM_DEBUG("mtrr_del=%d\n", retval); + } + if (drm_core_has_AGP(dev) && dev->agp) { + kfree(dev->agp); + dev->agp = NULL; + } +error_agp: + drm_ht_remove(&dev->map_hash); return retcode; } -- 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