[Intel-gfx] [PATCH] drm: remove mode from list and destroy it in order
Ma, Ling
ling.ma at intel.com
Mon Jun 8 14:18:09 CEST 2009
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
>
More information about the Intel-gfx
mailing list