소스 검색

msm: camera: cdm: Resolve potential data race condition

Accessing cdm_mgr.nodes.device without holding lock
cam_cdm_intf_devices.lock.
So added locks before shared variable access to avoid
data race conditions.

CRs-Fixed: 3372392
Change-Id: If3045410df6ed5a224e62392b5e17d5f45339fa5
Signed-off-by: Dharmender Sharma <[email protected]>
Dharmender Sharma 2 년 전
부모
커밋
38cae31748
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      drivers/cam_cdm/cam_cdm_intf.c

+ 4 - 2
drivers/cam_cdm/cam_cdm_intf.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/delay.h>
@@ -768,10 +768,12 @@ static void cam_cdm_intf_component_unbind(struct device *dev,
 			CAM_ERR(CAM_CDM, "Valid node present in index=%d", i);
 			goto end;
 		}
-		mutex_destroy(&cdm_mgr.nodes[i].lock);
+		mutex_lock(&cdm_mgr.nodes[i].lock);
 		cdm_mgr.nodes[i].device = NULL;
 		cdm_mgr.nodes[i].data = NULL;
 		cdm_mgr.nodes[i].refcount = 0;
+		mutex_unlock(&cdm_mgr.nodes[i].lock);
+		mutex_destroy(&cdm_mgr.nodes[i].lock);
 	}
 
 	cdm_mgr.probe_done = false;