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

Commit d4061eaf authored by Junzhe Zou's avatar Junzhe Zou
Browse files

msm: camera: sync: delete cb from list before queue work



Delete cb list before adding work to workqueue, so that cb structure
will not be freed by other function when it is inside workqueue. cb
will free itself after dispatching.

Change-Id: I718c1c7a35603edc847043fdde272a4b407e824c
Signed-off-by: default avatarJunzhe Zou <jnzhezou@codeaurora.org>
parent e5c35251
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ int cam_sync_register_callback(sync_callback cb_func,
		sync_cb->sync_obj = sync_obj;
		INIT_WORK(&sync_cb->cb_dispatch_work,
			cam_sync_util_cb_dispatch);
		list_add_tail(&sync_cb->list, &row->callback_list);
		sync_cb->status = row->state;
		queue_work(sync_dev->work_queue,
			&sync_cb->cb_dispatch_work);
@@ -238,6 +237,8 @@ int cam_sync_signal(int32_t sync_obj, uint32_t status)
		spin_unlock_bh(&sync_dev->row_spinlocks[parent_info->sync_id]);
	}

	spin_unlock_bh(&sync_dev->row_spinlocks[sync_obj]);

	/*
	 * Now dispatch the various sync objects collected so far, in our
	 * list
@@ -251,10 +252,13 @@ int cam_sync_signal(int32_t sync_obj, uint32_t status)
		struct sync_user_payload *temp_payload_info;

		signalable_row = sync_dev->sync_table + list_info->sync_obj;

		spin_lock_bh(&sync_dev->row_spinlocks[list_info->sync_obj]);
		/* Dispatch kernel callbacks if any were registered earlier */
		list_for_each_entry_safe(sync_cb,
			temp_sync_cb, &signalable_row->callback_list, list) {
			sync_cb->status = list_info->status;
			list_del_init(&sync_cb->list);
			queue_work(sync_dev->work_queue,
				&sync_cb->cb_dispatch_work);
		}
@@ -291,12 +295,12 @@ int cam_sync_signal(int32_t sync_obj, uint32_t status)
		 */
		complete_all(&signalable_row->signaled);

		spin_unlock_bh(&sync_dev->row_spinlocks[list_info->sync_obj]);

		list_del_init(&list_info->list);
		kfree(list_info);
	}

	spin_unlock_bh(&sync_dev->row_spinlocks[sync_obj]);

	return rc;
}

+0 −4
Original line number Diff line number Diff line
@@ -349,10 +349,6 @@ void cam_sync_util_cb_dispatch(struct work_struct *cb_dispatch_work)
		struct sync_callback_info,
		cb_dispatch_work);

	spin_lock_bh(&sync_dev->row_spinlocks[cb_info->sync_obj]);
	list_del_init(&cb_info->list);
	spin_unlock_bh(&sync_dev->row_spinlocks[cb_info->sync_obj]);

	cb_info->callback_func(cb_info->sync_obj,
		cb_info->status,
		cb_info->cb_data);