summaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorThomas Meyer <thomas@m3y3r.de>2011-11-29 16:08:00 -0500
committerSteven Rostedt <rostedt@goodmis.org>2012-02-13 13:48:11 -0500
commit47b0edcb599ea6eb9ef16d3a08932a0e01485293 (patch)
treec72965c718a4e50a845c1e0ec898fc2d86825104 /kernel/trace
parent95100358491abaa2e9a5483811370059bbca4645 (diff)
tracing/trivial: Use kcalloc instead of kzalloc to allocate array
The advantage of kcalloc is, that will prevent integer overflows which could result from the multiplication of number of elements and size and it is also a bit nicer to read. The semantic patch that makes this change is available in https://lkml.org/lkml/2011/11/25/107 Link: http://lkml.kernel.org/r/1322600880.1534.347.camel@localhost.localdomain Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/ftrace.c2
-rw-r--r--kernel/trace/trace_events_filter.c7
-rw-r--r--kernel/trace/trace_syscalls.c4
3 files changed, 6 insertions, 7 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index e2e0597c0845..d1499e910fe8 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1129,7 +1129,7 @@ static struct ftrace_hash *alloc_ftrace_hash(int size_bits)
1129 return NULL; 1129 return NULL;
1130 1130
1131 size = 1 << size_bits; 1131 size = 1 << size_bits;
1132 hash->buckets = kzalloc(sizeof(*hash->buckets) * size, GFP_KERNEL); 1132 hash->buckets = kcalloc(size, sizeof(*hash->buckets), GFP_KERNEL);
1133 1133
1134 if (!hash->buckets) { 1134 if (!hash->buckets) {
1135 kfree(hash); 1135 kfree(hash);
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 24aee7127451..76afaee99dbc 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -685,7 +685,7 @@ find_event_field(struct ftrace_event_call *call, char *name)
685 685
686static int __alloc_pred_stack(struct pred_stack *stack, int n_preds) 686static int __alloc_pred_stack(struct pred_stack *stack, int n_preds)
687{ 687{
688 stack->preds = kzalloc(sizeof(*stack->preds)*(n_preds + 1), GFP_KERNEL); 688 stack->preds = kcalloc(n_preds + 1, sizeof(*stack->preds), GFP_KERNEL);
689 if (!stack->preds) 689 if (!stack->preds)
690 return -ENOMEM; 690 return -ENOMEM;
691 stack->index = n_preds; 691 stack->index = n_preds;
@@ -826,8 +826,7 @@ static int __alloc_preds(struct event_filter *filter, int n_preds)
826 if (filter->preds) 826 if (filter->preds)
827 __free_preds(filter); 827 __free_preds(filter);
828 828
829 filter->preds = 829 filter->preds = kcalloc(n_preds, sizeof(*filter->preds), GFP_KERNEL);
830 kzalloc(sizeof(*filter->preds) * n_preds, GFP_KERNEL);
831 830
832 if (!filter->preds) 831 if (!filter->preds)
833 return -ENOMEM; 832 return -ENOMEM;
@@ -1486,7 +1485,7 @@ static int fold_pred(struct filter_pred *preds, struct filter_pred *root)
1486 children = count_leafs(preds, &preds[root->left]); 1485 children = count_leafs(preds, &preds[root->left]);
1487 children += count_leafs(preds, &preds[root->right]); 1486 children += count_leafs(preds, &preds[root->right]);
1488 1487
1489 root->ops = kzalloc(sizeof(*root->ops) * children, GFP_KERNEL); 1488 root->ops = kcalloc(children, sizeof(*root->ops), GFP_KERNEL);
1490 if (!root->ops) 1489 if (!root->ops)
1491 return -ENOMEM; 1490 return -ENOMEM;
1492 1491
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index cb654542c1a1..43500153dd1e 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -468,8 +468,8 @@ int __init init_ftrace_syscalls(void)
468 unsigned long addr; 468 unsigned long addr;
469 int i; 469 int i;
470 470
471 syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * 471 syscalls_metadata = kcalloc(NR_syscalls, sizeof(*syscalls_metadata),
472 NR_syscalls, GFP_KERNEL); 472 GFP_KERNEL);
473 if (!syscalls_metadata) { 473 if (!syscalls_metadata) {
474 WARN_ON(1); 474 WARN_ON(1);
475 return -ENOMEM; 475 return -ENOMEM;