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

Commit 0cd53d07 authored by Krupal Divvela's avatar Krupal Divvela Committed by VijayaKumar T M
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.

CRs-Fixed: 2038086
Change-Id: Ia9fdfd5a766add2f8d99003b0c2bfe7d34d57a09
Signed-off-by: default avatarKrupal Divvela <kdivvela@codeaurora.org>
Signed-off-by: default avatarannamraj <annamraj@codeaurora.org>
Signed-off-by: default avatarVijayaKumar T M <vtmuni@codeaurora.org>
parent ff71d910
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -747,9 +747,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;
}

/*
@@ -761,9 +765,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;

}

/*
@@ -775,9 +784,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;
}

/*