From d3eddffe71dfe33f27891355c8ff2a28ddfc2069 Mon Sep 17 00:00:00 2001 From: Hyuntae Kim Date: Mon, 8 Jun 2020 14:19:42 +0900 Subject: [PATCH] Fix resource manager memory leak issue Change-Id: I1e109efe9e54aa566236d5c0857a50334e9a573f --- packaging/libmm-camcorder.spec | 2 +- src/mm_camcorder_rm.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index c33c638..d539002 100644 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -1,6 +1,6 @@ Name: libmm-camcorder Summary: Camera and recorder library -Version: 0.10.203 +Version: 0.10.204 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_camcorder_rm.c b/src/mm_camcorder_rm.c index 0d8ccb5..104f3b2 100644 --- a/src/mm_camcorder_rm.c +++ b/src/mm_camcorder_rm.c @@ -216,23 +216,37 @@ int _mmcamcorder_rm_deallocate(MMHandleType handle) rm_device_request_s requested; mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + rm_device_return_s *r_devices; if (!hcamcorder->rm_handle) { _mmcam_dbg_err("Resource is not initialized "); return MM_ERROR_RESOURCE_NOT_INITIALIZED; } - if (hcamcorder->returned_devices.allocated_num > 0) { + r_devices = &hcamcorder->returned_devices; + + if (r_devices->allocated_num > 0) { memset(&requested, 0x0, sizeof(rm_device_request_s)); - requested.request_num = hcamcorder->returned_devices.allocated_num; + requested.request_num = r_devices->allocated_num; for (idx = 0; idx < requested.request_num; idx++) - requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx]; + requested.device_id[idx] = r_devices->device_id[idx]; rm_ret = rm_deallocate_resources(hcamcorder->rm_handle, &requested); if (rm_ret != RM_OK) _mmcam_dbg_err("Resource deallocation request failed "); } + for (idx = 0; idx < r_devices->allocated_num; idx++) { + if (r_devices->device_node[idx]) { + free(r_devices->device_node[idx]); + r_devices->device_node[idx] = NULL; + } + if (r_devices->omx_comp_name[idx]) { + free(r_devices->omx_comp_name[idx]); + r_devices->omx_comp_name[idx] = NULL; + } + } + return MM_ERROR_NONE; } -- 2.34.1