Skip to content

Commit

Permalink
media: staging: rkisp1: cap: protect buf.curr and buf.next with buf.lock
Browse files Browse the repository at this point in the history
The spinlock buf.lock should protect access to the buffers.
This includes the buffers in buf.queue and also buf.curr and
buf.next. The function 'rkisp1_set_next_buf' access buf.next
therefore it should also be protected with the lock.

Signed-off-by: Dafna Hirschfeld <[email protected]>
Acked-by: Helen Koike <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Dafna Hirschfeld authored and sigmaris committed Aug 8, 2020
1 parent 6fbb131 commit e922995
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/staging/media/rkisp1/rkisp1-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,11 @@ static void rkisp1_set_next_buf(struct rkisp1_capture *cap)
static void rkisp1_handle_buffer(struct rkisp1_capture *cap)
{
struct rkisp1_isp *isp = &cap->rkisp1->isp;
struct rkisp1_buffer *curr_buf = cap->buf.curr;
struct rkisp1_buffer *curr_buf;
unsigned long flags;

spin_lock_irqsave(&cap->buf.lock, flags);
curr_buf = cap->buf.curr;

if (curr_buf) {
curr_buf->vb.sequence = atomic_read(&isp->frame_sequence);
Expand All @@ -640,9 +641,9 @@ static void rkisp1_handle_buffer(struct rkisp1_capture *cap)
queue);
list_del(&cap->buf.next->queue);
}
spin_unlock_irqrestore(&cap->buf.lock, flags);

rkisp1_set_next_buf(cap);
spin_unlock_irqrestore(&cap->buf.lock, flags);
}

void rkisp1_capture_isr(struct rkisp1_device *rkisp1)
Expand Down

0 comments on commit e922995

Please sign in to comment.