Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-2.6-cm

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-2.6-cm:
kmemleak: Allow kmemleak metadata allocations to fail
kmemleak: remove memset by using kzalloc

+10 -9
+2 -4
mm/kmemleak-test.c
··· 75 75 * after the module is removed. 76 76 */ 77 77 for (i = 0; i < 10; i++) { 78 - elem = kmalloc(sizeof(*elem), GFP_KERNEL); 79 - pr_info("kmemleak: kmalloc(sizeof(*elem)) = %p\n", elem); 78 + elem = kzalloc(sizeof(*elem), GFP_KERNEL); 79 + pr_info("kmemleak: kzalloc(sizeof(*elem)) = %p\n", elem); 80 80 if (!elem) 81 81 return -ENOMEM; 82 - memset(elem, 0, sizeof(*elem)); 83 82 INIT_LIST_HEAD(&elem->list); 84 - 85 83 list_add_tail(&elem->list, &test_list); 86 84 } 87 85
+8 -5
mm/kmemleak.c
··· 113 113 #define BYTES_PER_POINTER sizeof(void *) 114 114 115 115 /* GFP bitmask for kmemleak internal allocations */ 116 - #define GFP_KMEMLEAK_MASK (GFP_KERNEL | GFP_ATOMIC) 116 + #define gfp_kmemleak_mask(gfp) (((gfp) & (GFP_KERNEL | GFP_ATOMIC)) | \ 117 + __GFP_NORETRY | __GFP_NOMEMALLOC | \ 118 + __GFP_NOWARN) 117 119 118 120 /* scanning area inside a memory block */ 119 121 struct kmemleak_scan_area { ··· 513 511 struct kmemleak_object *object; 514 512 struct prio_tree_node *node; 515 513 516 - object = kmem_cache_alloc(object_cache, gfp & GFP_KMEMLEAK_MASK); 514 + object = kmem_cache_alloc(object_cache, gfp_kmemleak_mask(gfp)); 517 515 if (!object) { 518 - kmemleak_stop("Cannot allocate a kmemleak_object structure\n"); 516 + pr_warning("Cannot allocate a kmemleak_object structure\n"); 517 + kmemleak_disable(); 519 518 return NULL; 520 519 } 521 520 ··· 737 734 return; 738 735 } 739 736 740 - area = kmem_cache_alloc(scan_area_cache, gfp & GFP_KMEMLEAK_MASK); 737 + area = kmem_cache_alloc(scan_area_cache, gfp_kmemleak_mask(gfp)); 741 738 if (!area) { 742 - kmemleak_warn("Cannot allocate a scan area\n"); 739 + pr_warning("Cannot allocate a scan area\n"); 743 740 goto out; 744 741 } 745 742