media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity
[ Upstream commit 8f94b49a5b5d386c038e355bef6347298aabd211 ]
CVE-2024-27077
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Huang Cun <cunhuang@tencent.com>
Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
This commit is contained in:
parent
7615677328
commit
1ec3edaed8
|
@ -799,11 +799,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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue