'vb' null check should be done before dereferencing it in
tw5864_handle_frame, otherwise a NULL pointer dereference
may occur.
Fixes: 34d1324edd31 ("[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>
        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.