[Intel-gfx] [PATCH] drm: remove mode from list and destroy it in order

Jesse Barnes jbarnes at virtuousgeek.org
Wed Jun 10 02:32:56 CEST 2009


Seems ok to me, but I'd have to audit the mode list handling to be sure
it's ok; there may be other bugs lurking...

Dave?

Jesse

On Mon, 8 Jun 2009 20:18:09 +0800
"Ma, Ling" <ling.ma at intel.com> wrote:

> Any comments ?
> 
> Thanks
> Ma Ling 
> 
> >-----Original Message-----
> >From: intel-gfx-bounces at lists.freedesktop.org 
> >[mailto:intel-gfx-bounces at lists.freedesktop.org] On Behalf Of Ma Ling
> >Sent: Friday, June 05, 2009 5:16 PM
> >To: dri-devel at lists.sourceforge.net
> >Cc: intel-gfx at lists.freedesktop.org
> >Subject: [Intel-gfx] [PATCH] drm: remove mode from list and 
> >destroy it in order
> >
> >Usually We create drm mode by drm_mode_create function which 
> >also will assign ID
> >to this mode by drm_mode_object_get function, then insert this 
> >new mode into 
> >mode list by list_add function. So when destroying mode, we 
> >need to remove mode
> >from list, then free ID and allocated memory by 
> >drm_mode_destroy function,
> >otherwise memory leak.
> >
> >Signed-off-by: Ma Ling <ling.ma at intel.com>
> >---
> > drivers/gpu/drm/drm_crtc.c |   13 +++++++++----
> > 1 files changed, 9 insertions(+), 4 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> >index 94a7688..03a7b30 100644
> >--- a/drivers/gpu/drm/drm_crtc.c
> >+++ b/drivers/gpu/drm/drm_crtc.c
> >@@ -423,7 +423,6 @@ void drm_mode_remove(struct drm_connector 
> >*connector,
> > 		     struct drm_display_mode *mode)
> > {
> > 	list_del(&mode->head);
> >-	kfree(mode);
> > }
> > EXPORT_SYMBOL(drm_mode_remove);
> > 
> >@@ -485,14 +484,20 @@ void drm_connector_cleanup(struct 
> >drm_connector *connector)
> > 	struct drm_device *dev = connector->dev;
> > 	struct drm_display_mode *mode, *t;
> > 
> >-	list_for_each_entry_safe(mode, t, 
> >&connector->probed_modes, head)
> >+	list_for_each_entry_safe(mode, t, 
> >&connector->probed_modes, head) {
> > 		drm_mode_remove(connector, mode);
> >+		drm_mode_destroy(dev, mode);
> >+	}
> > 
> >-	list_for_each_entry_safe(mode, t, &connector->modes, head)
> >+	list_for_each_entry_safe(mode, t, &connector->modes, head) {
> > 		drm_mode_remove(connector, mode);
> >+		drm_mode_destroy(dev, mode);
> >+	}
> > 
> >-	list_for_each_entry_safe(mode, t, &connector->user_modes,
> >head)
> >+	list_for_each_entry_safe(mode, t, 
> >&connector->user_modes, head) {
> > 		drm_mode_remove(connector, mode);
> >+		drm_mode_destroy(dev, mode);
> >+	}
> > 
> > 	mutex_lock(&dev->mode_config.mutex);
> > 	drm_mode_object_put(dev, &connector->base);
> >-- 
> >1.5.4.4
> >
> >
> >
> >_______________________________________________
> >Intel-gfx mailing list
> >Intel-gfx at lists.freedesktop.org
> >http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> >
> ------------------------------------------------------------------------------
> OpenSolaris 2009.06 is a cutting edge operating system for
> enterprises looking to deploy the next generation of Solaris that
> includes the latest innovations from Sun and the OpenSource
> community. Download a copy and enjoy capabilities such as Networking,
> Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get
> --
> _______________________________________________
> Dri-devel mailing list
> Dri-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dri-devel
> 




More information about the Intel-gfx mailing list