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...@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 ------------------------------------------------------------------------------ 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dri-devel