These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / platform / s5p-mfc / s5p_mfc_opr.c
index 00a1d8b..1e72502 100644 (file)
@@ -37,10 +37,9 @@ void s5p_mfc_init_regs(struct s5p_mfc_dev *dev)
                dev->mfc_regs = s5p_mfc_init_regs_v6_plus(dev);
 }
 
-int s5p_mfc_alloc_priv_buf(struct device *dev,
+int s5p_mfc_alloc_priv_buf(struct device *dev, dma_addr_t base,
                                        struct s5p_mfc_priv_buf *b)
 {
-
        mfc_debug(3, "Allocating priv: %zu\n", b->size);
 
        b->virt = dma_alloc_coherent(dev, b->size, &b->dma, GFP_KERNEL);
@@ -50,6 +49,14 @@ int s5p_mfc_alloc_priv_buf(struct device *dev,
                return -ENOMEM;
        }
 
+       if (b->dma < base) {
+               mfc_err("Invaling memory configuration!\n");
+               mfc_err("Allocated buffer (%pad) is lower than memory base address (%pad)\n",
+                       &b->dma, &base);
+               dma_free_coherent(dev, b->size, b->virt, b->dma);
+               return -ENOMEM;
+       }
+
        mfc_debug(3, "Allocated addr %p %pad\n", b->virt, &b->dma);
        return 0;
 }