Skip to contentSkip to conversation

perf/hwbp: Fix cleanup in case of kzalloc failure

PATCH In review Daniel Baluta 2 participants 4 messages Feb 6, 2013 – Feb 15, 2013 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/hwbp: Fix cleanup in case of kzalloc failure

Obviously this is a typo and could result in memory leaks if kzalloc fails on a given cpu.

---
 kernel/events/hw_breakpoint.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/events/hw_breakpoint.c +1 -1
index fe8a916..a64f8ae 100644
@@ -676,7 +676,7 @@ int __init init_hw_breakpoint(void)
  err_alloc:
 	for_each_possible_cpu(err_cpu) {
 		for (i = 0; i < TYPE_MAX; i++)
-			kfree(per_cpu(nr_task_bp_pinned[i], cpu));
+			kfree(per_cpu(nr_task_bp_pinned[i], err_cpu));
 		if (err_cpu == cpu)
 			break;
 	}
Signature · 1 line
1.7.5.4
Acked-by on v1 1/1
#1 lore raw

2013/2/6 Daniel Baluta <[email protected]>:

Quoted 4 lines

Obviously this is a typo and could result in memory leaks if kzalloc fails on a given cpu.

Good catch!

Quoted 20 lines
---
 kernel/events/hw_breakpoint.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/events/hw_breakpoint.c +1 -2
index fe8a916..a64f8ae 100644
@@ -676,7 +676,7 @@ int __init init_hw_breakpoint(void)
  err_alloc:
        for_each_possible_cpu(err_cpu) {
                for (i = 0; i < TYPE_MAX; i++)
-                       kfree(per_cpu(nr_task_bp_pinned[i], cpu));
+                       kfree(per_cpu(nr_task_bp_pinned[i], err_cpu));
                if (err_cpu == cpu)
                        break;
        }
--

1.7.5.4

#2 lore raw

[tip:perf/urgent] perf/hwbp: Fix cleanup in case of kzalloc() failure

In reply to Daniel Baluta
Commit-ID:  e97cbe3edf7d88aad4c21dd3de124d9f9d039881
Gitweb:     http://git.kernel.org/tip/e97cbe3edf7d88aad4c21dd3de124d9f9d039881
Author:     Daniel Baluta <[email protected]>
AuthorDate: Wed, 6 Feb 2013 23:29:20 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 7 Feb 2013 11:52:19 +0100

perf/hwbp: Fix cleanup in case of kzalloc() failure

Obviously this is a typo and could result in memory leaks if kzalloc fails on a given cpu.

---
 kernel/events/hw_breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/hw_breakpoint.c +1 -1
index fe8a916..a64f8ae 100644
@@ -676,7 +676,7 @@ int __init init_hw_breakpoint(void)
  err_alloc:
 	for_each_possible_cpu(err_cpu) {
 		for (i = 0; i < TYPE_MAX; i++)
-			kfree(per_cpu(nr_task_bp_pinned[i], cpu));
+			kfree(per_cpu(nr_task_bp_pinned[i], err_cpu));
 		if (err_cpu == cpu)
 			break;
 	}
#3 lore raw
In reply to Daniel Baluta
Commit-ID:  02e176af92f3e2e9ec3a48792036566af2dcd534
Gitweb:     http://git.kernel.org/tip/02e176af92f3e2e9ec3a48792036566af2dcd534
Author:     Daniel Baluta <[email protected]>
AuthorDate: Wed, 6 Feb 2013 23:29:20 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 14 Feb 2013 17:06:39 -0300

perf/hwbp: Fix cleanup in case of kzalloc failure

Obviously this is a typo and could result in memory leaks if kzalloc fails on a given cpu.

---
 kernel/events/hw_breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/hw_breakpoint.c +1 -1
index fe8a916..a64f8ae 100644
@@ -676,7 +676,7 @@ int __init init_hw_breakpoint(void)
  err_alloc:
 	for_each_possible_cpu(err_cpu) {
 		for (i = 0; i < TYPE_MAX; i++)
-			kfree(per_cpu(nr_task_bp_pinned[i], cpu));
+			kfree(per_cpu(nr_task_bp_pinned[i], err_cpu));
 		if (err_cpu == cpu)
 			break;
 	}