]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: ti-vpe: vpe: Add missing null pointer checks
authorBenoit Parrot <bparrot@ti.com>
Mon, 7 Oct 2019 15:09:51 +0000 (12:09 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 10 Oct 2019 16:42:44 +0000 (13:42 -0300)
A few NULL pointer checks were missing.
Add check with appropriate return code.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/ti-vpe/vpe.c

index 5ba72445584da76dc915b7d9e0d99d429e408515..56f60dbea15cc4002df725de944bb5bc58c5a373 100644 (file)
@@ -1537,6 +1537,8 @@ static int vpe_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
                return -EINVAL;
 
        q_data = get_q_data(ctx, f->type);
+       if (!q_data)
+               return -EINVAL;
 
        pix->width = q_data->width;
        pix->height = q_data->height;
@@ -2001,6 +2003,8 @@ static int vpe_queue_setup(struct vb2_queue *vq,
        struct vpe_q_data *q_data;
 
        q_data = get_q_data(ctx, vq->type);
+       if (!q_data)
+               return -EINVAL;
 
        *nplanes = q_data->nplanes;
 
@@ -2025,6 +2029,8 @@ static int vpe_buf_prepare(struct vb2_buffer *vb)
        vpe_dbg(ctx->dev, "type: %d\n", vb->vb2_queue->type);
 
        q_data = get_q_data(ctx, vb->vb2_queue->type);
+       if (!q_data)
+               return -EINVAL;
        num_planes = q_data->nplanes;
 
        if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
@@ -2481,7 +2487,12 @@ static int vpe_probe(struct platform_device *pdev)
        mutex_init(&dev->dev_mutex);
 
        dev->res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-                       "vpe_top");
+                                               "vpe_top");
+       if (!dev->res) {
+               dev_err(&pdev->dev, "missing 'vpe_top' resources data\n");
+               return -ENODEV;
+       }
+
        /*
         * HACK: we get resource info from device tree in the form of a list of
         * VPE sub blocks, the driver currently uses only the base of vpe_top