From: Hans Verkuil <hans.verkuil@xxxxxxxxx> The dma-contig and dma-sg memops require a valid struct device for the DMA to be handled correctly. Call WARN_ON and return ERR_PTR(-EINVAL) if it was NULL. Setting the correct device pointer was forgotten in several new driver submissions. This was caught during code review, but it really should be caught in the code. Signed-off-by: Hans Verkuil <hans.verkuil@xxxxxxxxx> --- drivers/media/v4l2-core/videobuf2-dma-contig.c | 9 +++++++++ drivers/media/v4l2-core/videobuf2-dma-sg.c | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 863f658..925b34b 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c @@ -141,6 +141,9 @@ static void *vb2_dc_alloc(struct device *dev, const struct dma_attrs *attrs, { struct vb2_dc_buf *buf; + if (WARN_ON(!dev)) + return ERR_PTR(-EINVAL); + buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); @@ -499,6 +502,9 @@ static void *vb2_dc_get_userptr(struct device *dev, unsigned long vaddr, return ERR_PTR(-EINVAL); } + if (WARN_ON(!dev)) + return ERR_PTR(-EINVAL); + buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); @@ -679,6 +685,9 @@ static void *vb2_dc_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, if (dbuf->size < size) return ERR_PTR(-EFAULT); + if (WARN_ON(!dev)) + return ERR_PTR(-EINVAL); + buf = kzalloc(sizeof(*buf), GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index e2afd2c..64a386d 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c @@ -232,6 +232,9 @@ static void *vb2_dma_sg_get_userptr(struct device *dev, unsigned long vaddr, DEFINE_DMA_ATTRS(attrs); struct frame_vector *vec; + if (WARN_ON(!dev)) + return ERR_PTR(-EINVAL); + dma_set_attr(DMA_ATTR_SKIP_CPU_SYNC, &attrs); buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) @@ -618,6 +621,9 @@ static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, struct vb2_dma_sg_buf *buf; struct dma_buf_attachment *dba; + if (WARN_ON(!dev)) + return ERR_PTR(-EINVAL); + if (dbuf->size < size) return ERR_PTR(-EFAULT); -- 2.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html