video: Fix memory leak of vidconsole device name
The vidconsole device name is allocated with strdup() but never marked
as allocated, so it is not freed when the device is removed. This causes
a memory leak on every video device probe/remove cycle.
Mark the name as allocated so driver model frees it on device removal,
and free it on the error path.
Fixes: 83510766c9 ("dm: video: Add a uclass for the text console")
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -795,8 +795,10 @@ static int video_post_probe(struct udevice *dev)
|
||||
ret = device_bind_driver(dev, drv_name, str, &cons);
|
||||
if (ret) {
|
||||
debug("%s: Cannot bind console driver\n", __func__);
|
||||
free(str);
|
||||
return ret;
|
||||
}
|
||||
device_set_name_alloced(cons);
|
||||
|
||||
ret = device_probe(cons);
|
||||
if (ret) {
|
||||
|
||||
Reference in New Issue
Block a user