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

Commit 7c7de82e authored by Arun Menon's avatar Arun Menon
Browse files

msm: vidc: Acquire lock before iterating over vb2_bufq list



In msm_comm_flush_in_invalid_state, the vb2_bufq list
was iterated over without holding the bufq lock. This
can lead to a race condition and corrupt the list, if we get an
EBD or FBD while flushing the buffers. This change helps avoid
any race condition while iterating over the vb2_bufq list.

Change-Id: I7be939aec0c7bd274a211c29537607f695758bfc
Signed-off-by: default avatarArun Menon <avmenon@codeaurora.org>
parent 77813844
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4025,6 +4025,7 @@ static void msm_comm_flush_in_invalid_state(struct msm_vidc_inst *inst)

		dprintk(VIDC_DBG, "Flushing buffers of type %d in bad state\n",
				port);
		mutex_lock(&inst->bufq[port].lock);
		list_for_each_safe(ptr, next, &inst->bufq[port].
				vb2_bufq.queued_list) {
			struct vb2_buffer *vb = container_of(ptr,
@@ -4033,10 +4034,9 @@ static void msm_comm_flush_in_invalid_state(struct msm_vidc_inst *inst)
			vb->v4l2_planes[0].bytesused = 0;
			vb->v4l2_planes[0].data_offset = 0;

			mutex_lock(&inst->bufq[port].lock);
			vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
			mutex_unlock(&inst->bufq[port].lock);
		}
		mutex_unlock(&inst->bufq[port].lock);
	}

	msm_vidc_queue_v4l2_event(inst, V4L2_EVENT_MSM_VIDC_FLUSH_DONE);