Преглед изворни кода

msm: eva: Fix KW issue

Change-Id: I93a8ff3ac20de452c2aa220a3dc4bc052880762e
Signed-off-by: George Shen <[email protected]>
George Shen пре 2 година
родитељ
комит
33825ea411

+ 3 - 12
msm/eva/msm_cvp.c

@@ -1325,10 +1325,7 @@ static int cvp_drain_fence_sched_list(struct msm_cvp_inst *inst)
 	if (!q)
 		return -EINVAL;
 
-	f  = list_first_entry(&q->sched_list,
-			struct cvp_fence_command,
-			list);
-	if (!f)
+	if (list_empty(&q->sched_list))
 		return rc;
 
 	mutex_lock(&q->lock);
@@ -1382,10 +1379,7 @@ static void cvp_clean_fence_queue(struct msm_cvp_inst *inst, int synx_state)
 	mutex_lock(&q->lock);
 	q->mode = OP_DRAINING;
 
-	f = list_first_entry(&q->wait_list,
-			struct cvp_fence_command,
-			list);
-	if (!f)
+	if (list_empty(&q->wait_list))
 		goto check_sched;
 
 	list_for_each_entry_safe(f, d, &q->wait_list, list) {
@@ -1403,10 +1397,7 @@ static void cvp_clean_fence_queue(struct msm_cvp_inst *inst, int synx_state)
 	}
 
 check_sched:
-	f = list_first_entry(&q->sched_list,
-			struct cvp_fence_command,
-			list);
-	if (!f) {
+	if (list_empty(&q->sched_list)) {
 		mutex_unlock(&q->lock);
 		return;
 	}

+ 6 - 2
msm/eva/msm_cvp_buf.c

@@ -1424,8 +1424,8 @@ static u32 msm_cvp_map_user_persist_buf(struct msm_cvp_inst *inst,
 {
 	u32 iova = 0;
 	struct msm_cvp_smem *smem = NULL;
-	struct list_head *ptr = (struct list_head *)0xdead;
-	struct list_head *next = (struct list_head *)0xdead;
+	struct list_head *ptr;
+	struct list_head *next;
 	struct cvp_internal_buf *pbuf;
 	struct dma_buf *dma_buf;
 
@@ -1439,6 +1439,10 @@ static u32 msm_cvp_map_user_persist_buf(struct msm_cvp_inst *inst,
 		return -EINVAL;
 
 	mutex_lock(&inst->persistbufs.lock);
+	if (!inst->persistbufs.list.next) {
+		mutex_unlock(&inst->persistbufs.lock);
+		return 0;
+	}
 	list_for_each_safe(ptr, next, &inst->persistbufs.list) {
 		if (!ptr)
 			return 0;

+ 9 - 1
msm/eva/msm_cvp_common.c

@@ -126,7 +126,12 @@ static void handle_sys_init_done(enum hal_command_response cmd, void *data)
 
 static void put_inst_helper(struct kref *kref)
 {
-	struct msm_cvp_inst *inst = container_of(kref,
+	struct msm_cvp_inst *inst;
+
+	if (!kref)
+		return;
+
+	inst = container_of(kref,
 			struct msm_cvp_inst, kref);
 
 	msm_cvp_destroy(inst);
@@ -1190,6 +1195,9 @@ void msm_cvp_ssr_handler(struct work_struct *work)
 	struct msm_cvp_core *core;
 	struct cvp_hfi_device *hdev;
 
+	if (!work)
+		return;
+
 	core = container_of(work, struct msm_cvp_core, ssr_work);
 	if (!core || !core->device) {
 		dprintk(CVP_ERR, "%s: Invalid params\n", __func__);

+ 6 - 3
msm/eva/msm_cvp_core.c

@@ -139,7 +139,7 @@ static void __deinit_session_queue(struct msm_cvp_inst *inst)
 	wake_up_all(&inst->session_queue.wq);
 }
 
-void *msm_cvp_open(int session_type, struct task_struct *task)
+struct msm_cvp_inst *msm_cvp_open(int session_type, struct task_struct *task)
 {
 	struct msm_cvp_inst *inst = NULL;
 	struct msm_cvp_core *core = NULL;
@@ -428,8 +428,11 @@ int msm_cvp_destroy(struct msm_cvp_inst *inst)
 
 static void close_helper(struct kref *kref)
 {
-	struct msm_cvp_inst *inst = container_of(kref,
-			struct msm_cvp_inst, kref);
+	struct msm_cvp_inst *inst;
+
+	if (!kref)
+		return;
+	inst = container_of(kref, struct msm_cvp_inst, kref);
 
 	msm_cvp_destroy(inst);
 }

+ 1 - 1
msm/eva/msm_cvp_core.h

@@ -29,7 +29,7 @@ enum session_type {
 	MSM_CVP_MAX_DEVICES = MSM_CVP_UNKNOWN,
 };
 
-void *msm_cvp_open(int session_type, struct task_struct *task);
+struct msm_cvp_inst *msm_cvp_open(int session_type, struct task_struct *task);
 int msm_cvp_close(void *instance);
 int msm_cvp_suspend(void);
 int msm_cvp_poll(void *instance, struct file *filp,

+ 5 - 2
msm/eva/msm_cvp_debug.c

@@ -477,8 +477,11 @@ static int publish_unreleased_reference(struct msm_cvp_inst *inst,
 
 static void put_inst_helper(struct kref *kref)
 {
-	struct msm_cvp_inst *inst = container_of(kref,
-			struct msm_cvp_inst, kref);
+	struct msm_cvp_inst *inst;
+
+	if (!kref)
+		return;
+	inst = container_of(kref, struct msm_cvp_inst, kref);
 
 	msm_cvp_destroy(inst);
 }

+ 10 - 0
msm/eva/msm_cvp_dsp.c

@@ -233,6 +233,8 @@ static int delete_dsp_session(struct msm_cvp_inst *inst,
 	mutex_lock(&buf_list->lock);
 	ptr_dsp_buf = &buf_list->list;
 	list_for_each_safe(ptr_dsp_buf, next_dsp_buf, &buf_list->list) {
+		if (!ptr_dsp_buf)
+			break;
 		buf = list_entry(ptr_dsp_buf, struct cvp_internal_buf, list);
 		if (buf) {
 			dprintk(CVP_DSP, "fd in list 0x%x\n", buf->fd);
@@ -379,6 +381,8 @@ search_again:
 
 	mutex_lock(&me->fastrpc_driver_list.lock);
 	list_for_each_safe(ptr, next, &me->fastrpc_driver_list.list) {
+		if (!ptr)
+			break;
 		frpc_node = list_entry(ptr,
 			struct cvp_dsp_fastrpc_driver_entry, list);
 
@@ -991,6 +995,8 @@ static struct cvp_dsp_fastrpc_driver_entry *cvp_get_fastrpc_node_with_handle(
 
 	mutex_lock(&me->fastrpc_driver_list.lock);
 	list_for_each_safe(ptr, next, &me->fastrpc_driver_list.list) {
+		if (!ptr)
+			break;
 		tmp_node = list_entry(ptr,
 				struct cvp_dsp_fastrpc_driver_entry, list);
 		if (handle == tmp_node->handle) {
@@ -1189,6 +1195,8 @@ int cvp_dsp_del_sess(uint32_t handle, struct msm_cvp_inst *inst)
 	}
 	mutex_lock(&frpc_node->dsp_sessions.lock);
 	list_for_each_safe(ptr, next, &frpc_node->dsp_sessions.list) {
+		if (!ptr)
+			break;
 		sess = list_entry(ptr, struct msm_cvp_inst, dsp_list);
 		if (sess == inst) {
 			dprintk(CVP_DSP, "%s Find sess %pK to be deleted\n",
@@ -1989,6 +1997,8 @@ static void __dsp_cvp_mem_free(struct cvp_dsp_cmd_msg *cmd)
 	buf_list = &inst->cvpdspbufs;
 	mutex_lock(&buf_list->lock);
 	list_for_each_safe(ptr, next, &buf_list->list) {
+		if (!ptr)
+			break;
 		buf = list_entry(ptr, struct cvp_internal_buf, list);
 
 		if (!buf->smem) {