Skip to content

Commit

Permalink
media: tw5864: Fix possible NULL pointer dereference in tw5864_handle…
Browse files Browse the repository at this point in the history
…_frame

'vb' null check should be done before dereferencing it in
tw5864_handle_frame, otherwise a NULL pointer dereference
may occur.

Fixes: 34d1324 ("[media] pci: Add tw5864 driver")

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
  • Loading branch information
YueHaibing authored and mchehab committed Mar 29, 2019
1 parent f8ee34c commit 2e7682e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/media/pci/tw5864/tw5864-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,13 +1395,13 @@ static void tw5864_handle_frame(struct tw5864_h264_frame *frame)
input->vb = NULL;
spin_unlock_irqrestore(&input->slock, flags);

v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf);

if (!vb) { /* Gone because of disabling */
dev_dbg(&dev->pci->dev, "vb is empty, dropping frame\n");
return;
}

v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf);

/*
* Check for space.
* Mind the overhead of startcode emulation prevention.
Expand Down

0 comments on commit 2e7682e

Please sign in to comment.