[PATCH] drm: fix memory leak around mode_group
David Herrmann
dh.herrmann at gmail.com
Tue Apr 22 00:39:10 PDT 2014
Hi
On Fri, Apr 18, 2014 at 2:02 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> This mode group id_list was never being freed.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> drivers/gpu/drm/drm_crtc.c | 6 ++++++
> drivers/gpu/drm/drm_stub.c | 1 +
> include/drm/drm_crtc.h | 1 +
> 3 files changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index d8b7099..a3fe324 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1378,6 +1378,12 @@ static int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *gr
> return 0;
> }
>
> +void drm_mode_group_destroy(struct drm_mode_group *group)
> +{
> + kfree(group->id_list);
> + group->id_list = NULL;
> +}
> +
> /*
> * NOTE: Driver's shouldn't ever call drm_mode_group_init_legacy_group - it is
> * the drm core's responsibility to set up mode control groups.
> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> index 4c24c3a..80bc780 100644
> --- a/drivers/gpu/drm/drm_stub.c
> +++ b/drivers/gpu/drm/drm_stub.c
> @@ -371,6 +371,7 @@ static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
> spin_unlock_irqrestore(&drm_minor_lock, flags);
> minor->index = 0;
>
> + drm_mode_group_destroy(&minor->mode_group);
Nice catch, but this is racy regarding drm_unplug_dev(). Can we do it
in drm_minor_free() instead? Imho, given that this is a
memory-cleanup, not a runtime helper, it belongs there, anyway.
Thanks
David
More information about the dri-devel
mailing list