x86: add tizen_qemu_x86_defconfig & tizen_qemu_x86_64_defconfig
[platform/kernel/linux-rpi.git] / mm / kmemleak.c
index b57383c..b78861b 100644 (file)
@@ -789,6 +789,8 @@ static void add_scan_area(unsigned long ptr, size_t size, gfp_t gfp)
        unsigned long flags;
        struct kmemleak_object *object;
        struct kmemleak_scan_area *area = NULL;
+       unsigned long untagged_ptr;
+       unsigned long untagged_objp;
 
        object = find_and_get_object(ptr, 1);
        if (!object) {
@@ -797,6 +799,9 @@ static void add_scan_area(unsigned long ptr, size_t size, gfp_t gfp)
                return;
        }
 
+       untagged_ptr = (unsigned long)kasan_reset_tag((void *)ptr);
+       untagged_objp = (unsigned long)kasan_reset_tag((void *)object->pointer);
+
        if (scan_area_cache)
                area = kmem_cache_alloc(scan_area_cache, gfp_kmemleak_mask(gfp));
 
@@ -808,8 +813,8 @@ static void add_scan_area(unsigned long ptr, size_t size, gfp_t gfp)
                goto out_unlock;
        }
        if (size == SIZE_MAX) {
-               size = object->pointer + object->size - ptr;
-       } else if (ptr + size > object->pointer + object->size) {
+               size = untagged_objp + object->size - untagged_ptr;
+       } else if (untagged_ptr + size > untagged_objp + object->size) {
                kmemleak_warn("Scan area larger than object 0x%08lx\n", ptr);
                dump_object_info(object);
                kmem_cache_free(scan_area_cache, area);
@@ -1403,7 +1408,8 @@ static void kmemleak_scan(void)
 {
        unsigned long flags;
        struct kmemleak_object *object;
-       int i;
+       struct zone *zone;
+       int __maybe_unused i;
        int new_leaks = 0;
 
        jiffies_last_scan = jiffies;
@@ -1443,9 +1449,9 @@ static void kmemleak_scan(void)
         * Struct page scanning for each node.
         */
        get_online_mems();
-       for_each_online_node(i) {
-               unsigned long start_pfn = node_start_pfn(i);
-               unsigned long end_pfn = node_end_pfn(i);
+       for_each_populated_zone(zone) {
+               unsigned long start_pfn = zone->zone_start_pfn;
+               unsigned long end_pfn = zone_end_pfn(zone);
                unsigned long pfn;
 
                for (pfn = start_pfn; pfn < end_pfn; pfn++) {
@@ -1454,8 +1460,8 @@ static void kmemleak_scan(void)
                        if (!page)
                                continue;
 
-                       /* only scan pages belonging to this node */
-                       if (page_to_nid(page) != i)
+                       /* only scan pages belonging to this zone */
+                       if (page_zone(page) != zone)
                                continue;
                        /* only scan if page is in use */
                        if (page_count(page) == 0)