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

Commit 6e7f639d authored by Terence Ho's avatar Terence Ho
Browse files

msm: camera: Use mutex lock to avoid race condition



Use mutex lock before using queuing ioctls like
queuing, dequeing buffers to avoid race condition.

Change-Id: I59c70f2abe3daddf38761a2f17671d3d49f43989
CRs-fixed: 2038086
Signed-off-by: default avatarTerence Ho <terenceh@codeaurora.org>
parent e539a094
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -745,9 +745,13 @@ static int msm_fd_s_fmt_vid_out(struct file *file,
static int msm_fd_reqbufs(struct file *file,
	void *fh, struct v4l2_requestbuffers *req)
{
	int ret;
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);

	return vb2_reqbufs(&ctx->vb2_q, req);
	mutex_lock(&ctx->fd_device->recovery_lock);
	ret = vb2_reqbufs(&ctx->vb2_q, req);
	mutex_unlock(&ctx->fd_device->recovery_lock);
	return ret;
}

/*
@@ -759,9 +763,14 @@ static int msm_fd_reqbufs(struct file *file,
static int msm_fd_qbuf(struct file *file, void *fh,
	struct v4l2_buffer *pb)
{
	int ret;
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);

	return vb2_qbuf(&ctx->vb2_q, pb);
	mutex_lock(&ctx->fd_device->recovery_lock);
	ret = vb2_qbuf(&ctx->vb2_q, pb);
	mutex_unlock(&ctx->fd_device->recovery_lock);
	return ret;

}

/*
@@ -773,9 +782,13 @@ static int msm_fd_qbuf(struct file *file, void *fh,
static int msm_fd_dqbuf(struct file *file,
	void *fh, struct v4l2_buffer *pb)
{
	int ret;
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);

	return vb2_dqbuf(&ctx->vb2_q, pb, file->f_flags & O_NONBLOCK);
	mutex_lock(&ctx->fd_device->recovery_lock);
	ret = vb2_dqbuf(&ctx->vb2_q, pb, file->f_flags & O_NONBLOCK);
	mutex_unlock(&ctx->fd_device->recovery_lock);
	return ret;
}

/*