diff options
-rw-r--r-- | mm/kmemleak.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 31f01c5011e5..474379ea3cff 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
@@ -218,7 +218,8 @@ static int kmemleak_stack_scan = 1; | |||
218 | static DEFINE_MUTEX(scan_mutex); | 218 | static DEFINE_MUTEX(scan_mutex); |
219 | /* setting kmemleak=on, will set this var, skipping the disable */ | 219 | /* setting kmemleak=on, will set this var, skipping the disable */ |
220 | static int kmemleak_skip_disable; | 220 | static int kmemleak_skip_disable; |
221 | 221 | /* If there are leaks that can be reported */ | |
222 | static bool kmemleak_found_leaks; | ||
222 | 223 | ||
223 | /* | 224 | /* |
224 | * Early object allocation/freeing logging. Kmemleak is initialized after the | 225 | * Early object allocation/freeing logging. Kmemleak is initialized after the |
@@ -1382,9 +1383,12 @@ static void kmemleak_scan(void) | |||
1382 | } | 1383 | } |
1383 | rcu_read_unlock(); | 1384 | rcu_read_unlock(); |
1384 | 1385 | ||
1385 | if (new_leaks) | 1386 | if (new_leaks) { |
1387 | kmemleak_found_leaks = true; | ||
1388 | |||
1386 | pr_info("%d new suspected memory leaks (see " | 1389 | pr_info("%d new suspected memory leaks (see " |
1387 | "/sys/kernel/debug/kmemleak)\n", new_leaks); | 1390 | "/sys/kernel/debug/kmemleak)\n", new_leaks); |
1391 | } | ||
1388 | 1392 | ||
1389 | } | 1393 | } |
1390 | 1394 | ||
@@ -1592,6 +1596,8 @@ static void kmemleak_clear(void) | |||
1592 | spin_unlock_irqrestore(&object->lock, flags); | 1596 | spin_unlock_irqrestore(&object->lock, flags); |
1593 | } | 1597 | } |
1594 | rcu_read_unlock(); | 1598 | rcu_read_unlock(); |
1599 | |||
1600 | kmemleak_found_leaks = false; | ||
1595 | } | 1601 | } |
1596 | 1602 | ||
1597 | /* | 1603 | /* |
@@ -1685,12 +1691,11 @@ static const struct file_operations kmemleak_fops = { | |||
1685 | static void kmemleak_do_cleanup(struct work_struct *work) | 1691 | static void kmemleak_do_cleanup(struct work_struct *work) |
1686 | { | 1692 | { |
1687 | struct kmemleak_object *object; | 1693 | struct kmemleak_object *object; |
1688 | bool cleanup = scan_thread == NULL; | ||
1689 | 1694 | ||
1690 | mutex_lock(&scan_mutex); | 1695 | mutex_lock(&scan_mutex); |
1691 | stop_scan_thread(); | 1696 | stop_scan_thread(); |
1692 | 1697 | ||
1693 | if (cleanup) { | 1698 | if (!kmemleak_found_leaks) { |
1694 | rcu_read_lock(); | 1699 | rcu_read_lock(); |
1695 | list_for_each_entry_rcu(object, &object_list, object_list) | 1700 | list_for_each_entry_rcu(object, &object_list, object_list) |
1696 | delete_object_full(object->pointer); | 1701 | delete_object_full(object->pointer); |