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