From afb504ab340b4e357a2982c99fde0a96f33382b1 Mon Sep 17 00:00:00 2001 From: Mukund Madhusudan Atre Date: Sun, 16 Feb 2020 23:29:27 -0800 Subject: [PATCH] msm: camera: cdm: Fix component unbind failures in cdm hw In cdm hw unbind, smmu handle is destroyed before handler is unset. Also, mutex unlock is unbalanced during error case. Fix invalid unset handler call and unbalanced mutex in component unbind for hw cdm. CRs-Fixed: 2584631 Change-Id: I8e117ce9623ba631d9457ef851b8f271591091b6 Signed-off-by: Mukund Madhusudan Atre --- drivers/cam_cdm/cam_cdm_hw_core.c | 4 ++-- drivers/cam_cdm/cam_cdm_intf.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/cam_cdm/cam_cdm_hw_core.c b/drivers/cam_cdm/cam_cdm_hw_core.c index a78156243e3c..e5a8efeb6e70 100644 --- a/drivers/cam_cdm/cam_cdm_hw_core.c +++ b/drivers/cam_cdm/cam_cdm_hw_core.c @@ -1894,10 +1894,10 @@ static void cam_hw_cdm_component_unbind(struct device *dev, destroy_workqueue(cdm_core->bl_fifo[i].work_queue); } - if (cam_smmu_destroy_handle(cdm_core->iommu_hdl.non_secure)) - CAM_ERR(CAM_CDM, "Release iommu secure hdl failed"); cam_smmu_unset_client_page_fault_handler( cdm_core->iommu_hdl.non_secure, cdm_hw); + if (cam_smmu_destroy_handle(cdm_core->iommu_hdl.non_secure)) + CAM_ERR(CAM_CDM, "Release iommu secure hdl failed"); mutex_destroy(&cdm_hw->hw_mutex); kfree(cdm_hw->soc_info.soc_private); diff --git a/drivers/cam_cdm/cam_cdm_intf.c b/drivers/cam_cdm/cam_cdm_intf.c index dcdbc667f832..8f9c9ce0ecb4 100644 --- a/drivers/cam_cdm/cam_cdm_intf.c +++ b/drivers/cam_cdm/cam_cdm_intf.c @@ -620,7 +620,7 @@ static void cam_cdm_intf_component_unbind(struct device *dev, if (cam_virtual_cdm_remove(pdev)) { CAM_ERR(CAM_CDM, "Virtual CDM remove failed"); - goto end; + return; } put_cdm_mgr_refcount(); @@ -635,7 +635,6 @@ static void cam_cdm_intf_component_unbind(struct device *dev, if (cdm_mgr.nodes[i].device || cdm_mgr.nodes[i].data || (cdm_mgr.nodes[i].refcount != 0)) { CAM_ERR(CAM_CDM, "Valid node present in index=%d", i); - mutex_unlock(&cam_cdm_mgr_lock); goto end; } mutex_destroy(&cdm_mgr.nodes[i].lock);