@@ -710,6 +710,14 @@ static int vb2_dc_map_dmabuf(void *mem_priv)
return -EINVAL;
}
+ /* Verify the dmabuf is restricted if we are in restricted mode, this is done
+ * by validating there is no page entry for the dmabuf.
+ */
+ if (buf->vb->vb2_queue->restricted_mem && sg_page(sgt->sgl)) {
+ pr_err("restricted queue requires restricted dma_buf");
+ return -EINVAL;
+ }
+
/* checking if dmabuf is big enough to store contiguous chunk */
contig_size = vb2_dc_get_contiguous_size(sgt);
if (contig_size < buf->size) {
@@ -570,6 +570,14 @@ static int vb2_dma_sg_map_dmabuf(void *mem_priv)
return -EINVAL;
}
+ /* Verify the dmabuf is restricted if we are in restricted mode, this is done
+ * by validating there is no page entry for the dmabuf.
+ */
+ if (buf->vb->vb2_queue->restricted_mem && !sg_page(sgt->sgl)) {
+ pr_err("restricted queue requires restricted dma_buf");
+ return -EINVAL;
+ }
+
buf->dma_sgt = sgt;
buf->vaddr = NULL;