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

Commit b5bc8765 authored by annamraj's avatar annamraj
Browse files

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: default avatarannamraj <annamraj@codeaurora.org>
parent cea658fb
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1055,14 +1055,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;