Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b80b7a62 authored by Jeyaprakash Soundrapandian's avatar Jeyaprakash Soundrapandian Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: crm: Adds protection for task structure" into dev/msm-4.9-camx

parents 291818ec 0b4febae
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -98,8 +98,10 @@ static int cam_req_mgr_process_task(struct crm_workq_task *task)
static void cam_req_mgr_process_workq(struct work_struct *w)
{
	struct cam_req_mgr_core_workq *workq = NULL;
	struct crm_workq_task         *task, *task_save;
	struct crm_workq_task         *task;
	int32_t                        i = CRM_TASK_PRIORITY_0;
	unsigned long                  flags = 0;

	if (!w) {
		CAM_ERR(CAM_CRM, "NULL task pointer can not schedule");
		return;
@@ -108,15 +110,19 @@ static void cam_req_mgr_process_workq(struct work_struct *w)
		container_of(w, struct cam_req_mgr_core_workq, work);

	while (i < CRM_TASK_PRIORITY_MAX) {
		if (!list_empty(&workq->task.process_head[i])) {
			list_for_each_entry_safe(task, task_save,
				&workq->task.process_head[i], entry) {
		WORKQ_ACQUIRE_LOCK(workq, flags);
		while (!list_empty(&workq->task.process_head[i])) {
			task = list_first_entry(&workq->task.process_head[i],
				struct crm_workq_task, entry);
			atomic_sub(1, &workq->task.pending_cnt);
			list_del_init(&task->entry);
			WORKQ_RELEASE_LOCK(workq, flags);
			cam_req_mgr_process_task(task);
			}
			CAM_DBG(CAM_CRM, "processed task %pK free_cnt %d",
				task, atomic_read(&workq->task.free_cnt));
			WORKQ_ACQUIRE_LOCK(workq, flags);
		}
		WORKQ_RELEASE_LOCK(workq, flags);
		i++;
	}
}
@@ -267,6 +273,7 @@ void cam_req_mgr_workq_destroy(struct cam_req_mgr_core_workq **crm_workq)
			destroy_workqueue((*crm_workq)->job);
			(*crm_workq)->job = NULL;
		}
		kfree((*crm_workq)->task.pool);
		kfree(*crm_workq);
		*crm_workq = NULL;
	}