OSDN Git Service

media: videobuf2: Exit promptly if size = 0
authorRicardo Ribalda <ribalda@chromium.org>
Tue, 9 Mar 2021 20:51:08 +0000 (21:51 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 22 Mar 2021 12:03:24 +0000 (13:03 +0100)
Exit as soon as possible if a driver wants to allocate a buffer of
size 0, and print a warning to help fixing the issue.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/common/videobuf2/videobuf2-dma-sg.c

index 030e482..c5b06a5 100644 (file)
@@ -105,7 +105,7 @@ static void *vb2_dma_sg_alloc(struct device *dev, unsigned long dma_attrs,
        int ret;
        int num_pages;
 
-       if (WARN_ON(!dev))
+       if (WARN_ON(!dev) || WARN_ON(!size))
                return ERR_PTR(-EINVAL);
 
        buf = kzalloc(sizeof *buf, GFP_KERNEL);