video: vidconsole: Free cursor save buffer on device removal

The cursor save_data buffer is allocated when the cursor is enabled but
never freed. Add a pre_remove callback to free this buffer when the
vidconsole device is removed.

Fixes: aebedeac44 ("video: Provide a buffer to hold pixels behind the cursor")
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2026-01-03 09:57:34 -07:00
parent 571b7298e4
commit 9c19a957d3

View File

@@ -14,6 +14,7 @@
#include <command.h> #include <command.h>
#include <console.h> #include <console.h>
#include <log.h> #include <log.h>
#include <malloc.h>
#include <dm.h> #include <dm.h>
#include <video.h> #include <video.h>
#include <video_console.h> #include <video_console.h>
@@ -865,11 +866,21 @@ static int vidconsole_post_probe(struct udevice *dev)
return stdio_register(sdev); return stdio_register(sdev);
} }
static int vidconsole_pre_remove(struct udevice *dev)
{
struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
free(vc_priv->curs.save_data);
return 0;
}
UCLASS_DRIVER(vidconsole) = { UCLASS_DRIVER(vidconsole) = {
.id = UCLASS_VIDEO_CONSOLE, .id = UCLASS_VIDEO_CONSOLE,
.name = "vidconsole0", .name = "vidconsole0",
.pre_probe = vidconsole_pre_probe, .pre_probe = vidconsole_pre_probe,
.post_probe = vidconsole_post_probe, .post_probe = vidconsole_post_probe,
.pre_remove = vidconsole_pre_remove,
.per_device_auto = sizeof(struct vidconsole_priv), .per_device_auto = sizeof(struct vidconsole_priv),
}; };