media: platform: hantro_drv: Add missing media_entity_cleanup()

The media_entity_pads_init() (or media_entity_init()) function initializes
the media entity, but the driver forgets to call media_entity_cleanup()
in the error paths and remove function. Add the missing calls to fix the
API violation and prevent potential future memory leaks.

Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
Biren Pandya 2026-06-15 01:58:16 +05:30 committed by Hans Verkuil
parent 2be6ee8638
commit 7504c24636

View File

@ -771,8 +771,10 @@ static int hantro_register_entity(struct media_device *mdev,
return ret;
ret = media_device_register_entity(mdev, entity);
if (ret)
if (ret) {
media_entity_cleanup(entity);
return ret;
}
return 0;
}
@ -860,12 +862,13 @@ static int hantro_attach_func(struct hantro_dev *vpu,
err_rel_entity2:
media_device_unregister_entity(&func->sink);
media_entity_cleanup(&func->sink);
err_rel_entity1:
media_device_unregister_entity(&func->proc);
media_entity_cleanup(&func->proc);
err_rel_entity0:
media_device_unregister_entity(&func->vdev.entity);
media_entity_cleanup(&func->vdev.entity);
return ret;
}
@ -878,6 +881,9 @@ static void hantro_detach_func(struct hantro_func *func)
media_device_unregister_entity(&func->sink);
media_device_unregister_entity(&func->proc);
media_device_unregister_entity(&func->vdev.entity);
media_entity_cleanup(&func->sink);
media_entity_cleanup(&func->proc);
media_entity_cleanup(&func->vdev.entity);
}
static int hantro_add_func(struct hantro_dev *vpu, unsigned int funcid)