diff mbox

[RFC,v2,11/11] vb2: dma-contig: Add WARN_ON_ONCE() to check for potential bugs

Message ID 20161216012425.11179-12-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Pinchart Dec. 16, 2016, 1:24 a.m. UTC
From: Sakari Ailus <sakari.ailus@linux.intel.com>

The scatterlist should always be present when the cache would need to be
flushed. Each buffer type has its own means to provide that. Add
WARN_ON_ONCE() to check the scatterist exists.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/v4l2-core/videobuf2-dma-contig.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index a0e88ad93f07..9409f458cf89 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -122,6 +122,9 @@  static void vb2_dc_prepare(void *buf_priv)
 	if (!(buf->attrs & DMA_ATTR_NON_CONSISTENT))
 		return;
 
+	if (WARN_ON_ONCE(!sgt))
+		return;
+
 	dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents,
 			       buf->dma_dir);
 }
@@ -138,6 +141,9 @@  static void vb2_dc_finish(void *buf_priv)
 	if (!(buf->attrs & DMA_ATTR_NON_CONSISTENT))
 		return;
 
+	if (WARN_ON_ONCE(!sgt))
+		return;
+
 	dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir);
 }