msm: camera: Make use of mutex lock to avoid race condition

Make use of mutex lock to access IOCTL so that two threads
can avoid race condition.

Change-Id: I00db78a42c86eef8a157b5b3547e4ca0006b0853
Signed-off-by: annamraj <annamraj@codeaurora.org>
This commit is contained in:
annamraj 2017-07-19 16:52:55 +05:30 committed by Gerrit - the friendly Code Review server
parent a37c10a168
commit b8ec107574

View file

@ -1057,14 +1057,18 @@ static int msm_fd_s_ctrl(struct file *file, void *fh, struct v4l2_control *a)
a->value = ctx->format.size->work_size;
break;
case V4L2_CID_FD_WORK_MEMORY_FD:
mutex_lock(&ctx->fd_device->recovery_lock);
if (ctx->work_buf.fd != -1)
msm_fd_hw_unmap_buffer(&ctx->work_buf);
if (a->value >= 0) {
ret = msm_fd_hw_map_buffer(&ctx->mem_pool,
a->value, &ctx->work_buf);
if (ret < 0)
if (ret < 0) {
mutex_unlock(&ctx->fd_device->recovery_lock);
return ret;
}
}
mutex_unlock(&ctx->fd_device->recovery_lock);
break;
default:
return -EINVAL;