LinuxTV Patchwork media: tw5864: Fix possible NULL pointer dereference in tw5864_handle_frame

login
register
mail settings
Submitter YueHaibing
Date March 15, 2019, 2:01 a.m.
Message ID <20190315020124.18292-1-yuehaibing@huawei.com>
Download mbox | patch
Permalink /patch/55061/
State Accepted
Delegated to: Hans Verkuil
Headers show

Comments

YueHaibing - March 15, 2019, 2:01 a.m.
From: YueHaibing <yuehaibing@huawei.com>

'vb' null check should before dereference it in
tw5864_handle_frame, otherwise NULL pointer dereference
may occurs.

Fixes: 34d1324edd31 ("[media] pci: Add tw5864 driver")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/media/pci/tw5864/tw5864-video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c
index 5a1f3aa..434d313 100644
--- a/drivers/media/pci/tw5864/tw5864-video.c
+++ b/drivers/media/pci/tw5864/tw5864-video.c
@@ -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.

Privacy Policy