Quellcode durchsuchen

Merge "msm: eva: Adding kref count for cvp_get_inst_from_id"

qctecmdr vor 9 Monaten
Ursprung
Commit
ad72bdf79c
1 geänderte Dateien mit 6 neuen und 2 gelöschten Zeilen
  1. 6 2
      msm/eva/hfi_response_handler.c

+ 6 - 2
msm/eva/hfi_response_handler.c

@@ -487,7 +487,7 @@ retry:
 			}
 			}
 		}
 		}
 
 
-		inst = match ? inst : NULL;
+		inst = match && kref_get_unless_zero(&inst->kref) ? inst : NULL;
 		mutex_unlock(&core->lock);
 		mutex_unlock(&core->lock);
 	} else {
 	} else {
 		if (core->state == CVP_CORE_UNINIT)
 		if (core->state == CVP_CORE_UNINIT)
@@ -546,6 +546,7 @@ static int hfi_process_session_dump_notify(u32 device_id,
 	info->response_type = HAL_SESSION_DUMP_NOTIFY;
 	info->response_type = HAL_SESSION_DUMP_NOTIFY;
 	info->response.cmd = cmd_done;
 	info->response.cmd = cmd_done;
 
 
+	cvp_put_inst(inst);
 	return 0;
 	return 0;
 }
 }
 
 
@@ -584,7 +585,7 @@ static int hfi_process_session_cvp_msg(u32 device_id,
 	sess_msg = cvp_kmem_cache_zalloc(&cvp_driver->msg_cache, GFP_KERNEL);
 	sess_msg = cvp_kmem_cache_zalloc(&cvp_driver->msg_cache, GFP_KERNEL);
 	if (sess_msg == NULL) {
 	if (sess_msg == NULL) {
 		dprintk(CVP_ERR, "%s runs out msg cache memory\n", __func__);
 		dprintk(CVP_ERR, "%s runs out msg cache memory\n", __func__);
-		return -ENOMEM;
+		goto error_no_mem;
 	}
 	}
 
 
 	memcpy(&sess_msg->pkt, pkt, get_msg_size(pkt));
 	memcpy(&sess_msg->pkt, pkt, get_msg_size(pkt));
@@ -607,11 +608,14 @@ static int hfi_process_session_cvp_msg(u32 device_id,
 
 
 	info->response_type = HAL_NO_RESP;
 	info->response_type = HAL_NO_RESP;
 
 
+	cvp_put_inst(inst);
 	return 0;
 	return 0;
 
 
 error_handle_msg:
 error_handle_msg:
 	spin_unlock(&sq->lock);
 	spin_unlock(&sq->lock);
 	cvp_kmem_cache_free(&cvp_driver->msg_cache, sess_msg);
 	cvp_kmem_cache_free(&cvp_driver->msg_cache, sess_msg);
+error_no_mem:
+	cvp_put_inst(inst);
 	return -ENOMEM;
 	return -ENOMEM;
 }
 }