From: Limeng <[email protected]> When initialize VCHI_INSTANCE_T instance, it is a local variable in function vchiq_mmal_init(). In this way, there will be memory leak if vchiq instance is initialized failed or uninstall vchiq mmal driver. Therefore, add a VCHI_INSTANCE_T member struct vchiq_mmal_instance to save the vchiq instance, so that release vchiq instance if necessary.
Signed-off-by: Meng Li <[email protected]> --- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index d4c490cedae3..6a3ee47e7431 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -191,6 +191,8 @@ struct vchiq_mmal_instance { /* ordered workqueue to process all bulk operations */ struct workqueue_struct *bulk_wq; + + struct vchi_instance_handle *vchi_instance; }; static struct mmal_msg_context * @@ -2093,6 +2095,9 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance) idr_destroy(&instance->context_map); + if (instance->vchi_instance) + kfree(instance->vchi_instance); + kfree(instance); return status; @@ -2143,6 +2148,8 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) if (!instance) return -ENOMEM; + instance->vchi_instance = vchi_instance; + mutex_init(&instance->vchiq_mutex); instance->bulk_scratch = vmalloc(PAGE_SIZE); -- 2.17.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#9020): https://lists.yoctoproject.org/g/linux-yocto/message/9020 Mute This Topic: https://lists.yoctoproject.org/mt/76642859/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
