diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2016-07-21 09:14:03 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-08-24 10:18:42 -0300 |
commit | 10791829eb52d572915ef621f06e134488d4b204 (patch) | |
tree | dd18ba22b83a272911524270305dd9ccc6a86d8f /drivers/media/v4l2-core | |
parent | 0ff657b0f6120cb53f98b1b42c87af34670edff5 (diff) | |
download | talos-op-linux-10791829eb52d572915ef621f06e134488d4b204.tar.gz talos-op-linux-10791829eb52d572915ef621f06e134488d4b204.zip |
[media] vb2: add WARN_ONs checking if a valid struct device was passed
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@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-dma-contig.c | 9 | ||||
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-dma-sg.c | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 59fa204b15f3..fb6a177be461 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, unsigned long 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); @@ -493,6 +496,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); @@ -673,6 +679,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 e0165c10b82f..ecff8f492c4f 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c @@ -225,6 +225,9 @@ static void *vb2_dma_sg_get_userptr(struct device *dev, unsigned long vaddr, struct sg_table *sgt; struct frame_vector *vec; + if (WARN_ON(!dev)) + return ERR_PTR(-EINVAL); + buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); @@ -607,6 +610,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); |