msm: camera: protect list operations around a mutex.
The list in the generic buf manager may be operated upon
bu multiple user space processes. This calls for all list
operations, namely add and delete, to be atomic operations.
Change-Id: Ie6caf3e3a3704d0beabb41702e0d165deec73ff7
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
diff --git a/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c b/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
index 9af6674..77dc6f5 100644
--- a/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
+++ b/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
@@ -35,7 +35,9 @@
}
new_entry->session_id = buf_info->session_id;
new_entry->stream_id = buf_info->stream_id;
+ mutex_lock(&buf_mngr_dev->buf_q_lock);
list_add_tail(&new_entry->entry, &buf_mngr_dev->buf_qhead);
+ mutex_unlock(&buf_mngr_dev->buf_q_lock);
buf_info->index = new_entry->vb2_buf->v4l2_buf.index;
return 0;
}
@@ -55,7 +57,9 @@
(bufs->vb2_buf,
buf_info->session_id,
buf_info->stream_id);
+ mutex_lock(&buf_mngr_dev->buf_q_lock);
list_del_init(&bufs->entry);
+ mutex_unlock(&buf_mngr_dev->buf_q_lock);
kfree(bufs);
break;
}
@@ -76,7 +80,9 @@
(bufs->vb2_buf->v4l2_buf.index == buf_info->index)) {
ret = buf_mngr_dev->vb2_ops.put_buf(bufs->vb2_buf,
buf_info->session_id, buf_info->stream_id);
+ mutex_lock(&buf_mngr_dev->buf_q_lock);
list_del_init(&bufs->entry);
+ mutex_unlock(&buf_mngr_dev->buf_q_lock);
kfree(bufs);
break;
}
@@ -156,12 +162,14 @@
&msm_buf_mngr_dev->vb2_ops);
INIT_LIST_HEAD(&msm_buf_mngr_dev->buf_qhead);
+ mutex_init(&msm_buf_mngr_dev->buf_q_lock);
end:
return rc;
}
static void __exit msm_buf_mngr_exit(void)
{
+ mutex_destroy(&msm_buf_mngr_dev->buf_q_lock);
kfree(msm_buf_mngr_dev);
}
diff --git a/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.h b/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.h
index 7e588cc..a2b3a7e 100644
--- a/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.h
+++ b/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.h
@@ -33,6 +33,7 @@
struct msm_buf_mngr_device {
struct list_head buf_qhead;
+ struct mutex buf_q_lock;
struct msm_sd_subdev subdev;
struct msm_sd_req_vb2_q vb2_ops;
};