diff mbox series

drm/qxl: prevent memory leak

Message ID 20230322085847.3385930-1-zhouzongmin@kylinos.cn (mailing list archive)
State New, archived
Headers show
Series drm/qxl: prevent memory leak | expand

Commit Message

Zongmin Zhou March 22, 2023, 8:58 a.m. UTC
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>
---
 drivers/gpu/drm/qxl/qxl_display.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Dave Airlie Nov. 1, 2023, 2:58 a.m. UTC | #1
On Wed, 22 Mar 2023 at 19:04, Zongmin Zhou <zhouzongmin@kylinos.cn> wrote:
>
> 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>

Sorry for nobody picking up on this, qxl isn't really well staffed,

Reviewed-by: Dave Airlie <airlied@redhat.com>

Could one of the misc maintainers pick this up?

Dave.
Maxime Ripard Nov. 6, 2023, 9:49 a.m. UTC | #2
Hi,

On Wed, Nov 01, 2023 at 12:58:17PM +1000, Dave Airlie wrote:
> On Wed, 22 Mar 2023 at 19:04, Zongmin Zhou <zhouzongmin@kylinos.cn> wrote:
> >
> > 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>
> 
> Sorry for nobody picking up on this, qxl isn't really well staffed,
> 
> Reviewed-by: Dave Airlie <airlied@redhat.com>
> 
> Could one of the misc maintainers pick this up?

I just applied it to drm-misc-fixes

Maxime
Zongmin Zhou Nov. 8, 2023, 7:01 a.m. UTC | #3
Thanks for your reply.

Best regards!

On 2023/11/6 17:49, Maxime Ripard wrote:
> Hi,
>
> On Wed, Nov 01, 2023 at 12:58:17PM +1000, Dave Airlie wrote:
>> On Wed, 22 Mar 2023 at 19:04, Zongmin Zhou <zhouzongmin@kylinos.cn> wrote:
>>> 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>
>> Sorry for nobody picking up on this, qxl isn't really well staffed,
>>
>> Reviewed-by: Dave Airlie <airlied@redhat.com>
>>
>> Could one of the misc maintainers pick this up?
> I just applied it to drm-misc-fixes
>
> Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 6492a70e3c39..404b0483bb7c 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;