Merge tag 'drm-fixes-2019-01-11' of git://anongit.freedesktop.org/drm/drm
[linux-2.6-block.git] / mm / cma.c
index 4cb76121a3ab065de3157547e4f1b828d16f07ec..c7b39dd3b4f65f07e6b3ed5582601b52c9d8393b 100644 (file)
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -407,6 +407,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
        unsigned long pfn = -1;
        unsigned long start = 0;
        unsigned long bitmap_maxno, bitmap_no, bitmap_count;
+       size_t i;
        struct page *page = NULL;
        int ret = -ENOMEM;
 
@@ -466,6 +467,16 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
 
        trace_cma_alloc(pfn, page, count, align);
 
+       /*
+        * CMA can allocate multiple page blocks, which results in different
+        * blocks being marked with different tags. Reset the tags to ignore
+        * those page blocks.
+        */
+       if (page) {
+               for (i = 0; i < count; i++)
+                       page_kasan_tag_reset(page + i);
+       }
+
        if (ret && !no_warn) {
                pr_err("%s: alloc failed, req-size: %zu pages, ret: %d\n",
                        __func__, count, ret);