Skip to content

Commit 5b0022d

Browse files
rnavrostedt
authored andcommitted
ftrace: Check for successful allocation of hash
In register_ftrace_function_probe(), we are not checking the return value of alloc_and_copy_ftrace_hash(). The subsequent call to ftrace_match_records() may end up dereferencing the same. Add a check to ensure this doesn't happen. Link: http://lkml.kernel.org/r/26e92574f25ad23e7cafa3cf5f7a819de1832cbe.1562249521.git.naveen.n.rao@linux.vnet.ibm.com Cc: [email protected] Fixes: 1ec3a81 ("ftrace: Have each function probe use its own ftrace_ops") Signed-off-by: Naveen N. Rao <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 372e0d0 commit 5b0022d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/trace/ftrace.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4338,6 +4338,11 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
43384338
old_hash = *orig_hash;
43394339
hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, old_hash);
43404340

4341+
if (!hash) {
4342+
ret = -ENOMEM;
4343+
goto out;
4344+
}
4345+
43414346
ret = ftrace_match_records(hash, glob, strlen(glob));
43424347

43434348
/* Nothing found? */

0 commit comments

Comments
 (0)