virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.5 2/6] drm/qxl: prevent memory leak
       [not found] <20231115033459.1228900-1-sashal@kernel.org>
@ 2023-11-15  3:34 ` Sasha Levin
  2023-11-15  7:07   ` [Spice-devel] " Frediano Ziglio
  0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2023-11-15  3:34 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Zongmin Zhou, Dave Airlie, Maxime Ripard, Sasha Levin, kraxel,
	maarten.lankhorst, tzimmermann, airlied, daniel, virtualization,
	spice-devel, dri-devel

From: Zongmin Zhou <zhouzongmin@kylinos.cn>

[ Upstream commit 0e8b9f258baed25f1c5672613699247c76b007b5 ]

The allocated memory for qdev->dumb_heads should be released
in qxl_destroy_monitors_object before qxl suspend.
otherwise,qxl_create_monitors_object will be called to
reallocate memory for qdev->dumb_heads after qxl resume,
it will cause memory leak.

Signed-off-by: Zongmin Zhou <zhouzongmin@kylinos.cn>
Link: https://lore.kernel.org/r/20230801025309.4049813-1-zhouzongmin@kylinos.cn
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/qxl/qxl_display.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 6492a70e3c396..404b0483bb7cb 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -1229,6 +1229,9 @@ int qxl_destroy_monitors_object(struct qxl_device *qdev)
 	if (!qdev->monitors_config_bo)
 		return 0;
 
+	kfree(qdev->dumb_heads);
+	qdev->dumb_heads = NULL;
+
 	qdev->monitors_config = NULL;
 	qdev->ram_header->monitors_config = 0;
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Spice-devel] [PATCH AUTOSEL 6.5 2/6] drm/qxl: prevent memory leak
  2023-11-15  3:34 ` [PATCH AUTOSEL 6.5 2/6] drm/qxl: prevent memory leak Sasha Levin
@ 2023-11-15  7:07   ` Frediano Ziglio
  0 siblings, 0 replies; 2+ messages in thread
From: Frediano Ziglio @ 2023-11-15  7:07 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, stable, daniel, dri-devel, maarten.lankhorst,
	virtualization, Maxime Ripard, Zongmin Zhou, kraxel, tzimmermann,
	spice-devel, Dave Airlie

Il giorno mer 15 nov 2023 alle ore 06:57 Sasha Levin
<sashal@kernel.org> ha scritto:
>
> From: Zongmin Zhou <zhouzongmin@kylinos.cn>
>
> [ Upstream commit 0e8b9f258baed25f1c5672613699247c76b007b5 ]
>
> The allocated memory for qdev->dumb_heads should be released
> in qxl_destroy_monitors_object before qxl suspend.
> otherwise,qxl_create_monitors_object will be called to

Minor, typo: otherwise -> Otherwise.

> reallocate memory for qdev->dumb_heads after qxl resume,
> it will cause memory leak.
>
> Signed-off-by: Zongmin Zhou <zhouzongmin@kylinos.cn>
> Link: https://lore.kernel.org/r/20230801025309.4049813-1-zhouzongmin@kylinos.cn
> Reviewed-by: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/gpu/drm/qxl/qxl_display.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
> index 6492a70e3c396..404b0483bb7cb 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -1229,6 +1229,9 @@ int qxl_destroy_monitors_object(struct qxl_device *qdev)
>         if (!qdev->monitors_config_bo)
>                 return 0;
>
> +       kfree(qdev->dumb_heads);
> +       qdev->dumb_heads = NULL;
> +
>         qdev->monitors_config = NULL;
>         qdev->ram_header->monitors_config = 0;
>

Frediano

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-15  7:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20231115033459.1228900-1-sashal@kernel.org>
2023-11-15  3:34 ` [PATCH AUTOSEL 6.5 2/6] drm/qxl: prevent memory leak Sasha Levin
2023-11-15  7:07   ` [Spice-devel] " Frediano Ziglio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).