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;
        struct vpe_q_data *q_data;
 
        q_data = get_q_data(ctx, vq->type);
+       if (!q_data)
+               return -EINVAL;
 
        *nplanes = q_data->nplanes;
 
        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) {
        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