소스 검색

msm: eva: Avoid dereference NULL smem

Check and return error in case of NULL smem.

Change-Id: I0f1f6a0746fe2110e0f5f306c22133caba6f2d63
Signed-off-by: George Shen <[email protected]>
George Shen 3 년 전
부모
커밋
0e72292d71
4개의 변경된 파일22개의 추가작업 그리고 11개의 파일을 삭제
  1. 14 5
      msm/eva/msm_cvp_buf.c
  2. 1 1
      msm/eva/msm_cvp_buf.h
  3. 5 5
      msm/eva/msm_cvp_common.c
  4. 2 0
      msm/eva/msm_cvp_res_parse.c

+ 14 - 5
msm/eva/msm_cvp_buf.c

@@ -33,11 +33,17 @@
 	} while (0)
 
 
-void print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst,
+int print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst,
 		struct msm_cvp_smem *smem)
 {
-	if (!(tag & msm_cvp_debug) || !inst || !smem)
-		return;
+	if (!(tag & msm_cvp_debug))
+		return 0;
+
+	if (!inst || !smem) {
+		dprintk(CVP_ERR, "Invalid inst 0x%llx or smem 0x%llx\n",
+				inst, smem);
+		return -EINVAL;
+	}
 
 	if (smem->dma_buf) {
 		dprintk(tag,
@@ -46,6 +52,7 @@ void print_smem(u32 tag, const char *str, struct msm_cvp_inst *inst,
 			smem->size, smem->flags, smem->device_addr,
 			smem->bitmap_index, smem->refcount);
 	}
+	return 0;
 }
 
 static void print_internal_buffer(u32 tag, const char *str,
@@ -78,7 +85,9 @@ void print_cvp_buffer(u32 tag, const char *str, struct msm_cvp_inst *inst,
 static void _log_smem(struct inst_snapshot *snapshot, struct msm_cvp_inst *inst,
 		struct msm_cvp_smem *smem, bool logging)
 {
-	print_smem(CVP_ERR, "bufdump", inst, smem);
+
+	if (print_smem(CVP_ERR, "bufdump", inst, smem))
+		return;
 	if (!logging || !snapshot)
 		return;
 	if (snapshot && snapshot->smem_index < MAX_ENTRIES) {
@@ -941,7 +950,7 @@ void msm_cvp_print_inst_bufs(struct msm_cvp_inst *inst, bool log)
 			"---Buffer details for inst: %pK of type: %d---\n",
 			inst, inst->session_type);
 	mutex_lock(&inst->dma_cache.lock);
-	dprintk(CVP_ERR, "dma cache:\n");
+	dprintk(CVP_ERR, "dma cache: %d\n", inst->dma_cache.nr);
 	if (inst->dma_cache.nr <= MAX_DMABUF_NUMS)
 		for (i = 0; i < inst->dma_cache.nr; i++)
 			_log_smem(snap, inst, inst->dma_cache.entries[i], log);

+ 1 - 1
msm/eva/msm_cvp_buf.h

@@ -146,7 +146,7 @@ void print_cvp_buffer(u32 tag, const char *str,
 void print_client_buffer(u32 tag, const char *str,
 		struct msm_cvp_inst *inst,
 		struct eva_kmd_buffer *cbuf);
-void print_smem(u32 tag, const char *str,
+int print_smem(u32 tag, const char *str,
 		struct msm_cvp_inst *inst,
 		struct msm_cvp_smem *smem);
 

+ 5 - 5
msm/eva/msm_cvp_common.c

@@ -646,7 +646,11 @@ static void handle_sys_error(enum hal_command_response cmd, void *data)
 	cur_state = core->state;
 	core->state = CVP_CORE_UNINIT;
 	dprintk(CVP_WARN, "SYS_ERROR received for core %pK\n", core);
-	msm_cvp_noc_error_info(core);
+	if (response->status == CVP_ERR_NOC_ERROR) {
+		dprintk(CVP_WARN, "Got NOC error");
+		msm_cvp_noc_error_info(core);
+		MSM_CVP_ERROR(true);
+	}
 	call_hfi_op(hdev, flush_debug_queue, hdev->hfi_device_data);
 	list_for_each_entry(inst, &core->instances, list) {
 		dprintk(CVP_WARN,
@@ -672,10 +676,6 @@ static void handle_sys_error(enum hal_command_response cmd, void *data)
 
 	/* handle the hw error before core released to get full debug info */
 	msm_cvp_handle_hw_error(core);
-	if (response->status == CVP_ERR_NOC_ERROR) {
-		dprintk(CVP_WARN, "Got NOC error");
-		MSM_CVP_ERROR(true);
-	}
 
 	dprintk(CVP_CORE, "Calling core_release\n");
 	rc = call_hfi_op(hdev, core_release, hdev->hfi_device_data);

+ 2 - 0
msm/eva/msm_cvp_res_parse.c

@@ -962,6 +962,8 @@ int msm_cvp_smmu_fault_handler(struct iommu_domain *domain,
 	}
 
 	core->smmu_fault_count++;
+	if (!core->last_fault_addr)
+		core->last_fault_addr = iova;
 	dprintk(CVP_ERR, "%s - faulting address: %lx, %d\n",
 		__func__, iova, core->smmu_fault_count);