mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-12 16:15:05 -04:00
media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity
The entity->name (i.e. name) is allocated in v4l2_m2m_register_entity
but isn't freed in its following error-handling paths. This patch
adds such deallocation to prevent memleak of entity->name.
Fixes: be2fff6563 ("media: add helpers for memory-to-memory media controller")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
@@ -1087,11 +1087,17 @@ static int v4l2_m2m_register_entity(struct media_device *mdev,
|
||||
entity->function = function;
|
||||
|
||||
ret = media_entity_pads_init(entity, num_pads, pads);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
kfree(entity->name);
|
||||
entity->name = NULL;
|
||||
return ret;
|
||||
}
|
||||
ret = media_device_register_entity(mdev, entity);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
kfree(entity->name);
|
||||
entity->name = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user