diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-09-21 16:09:46 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-09-22 12:51:55 -0400 |
commit | aaaaf69ba76310abfa150f48784006cd1079ccf8 (patch) | |
tree | 8e041b3a11fed13c44f5e5b91b7193dae4523e4a | |
parent | 2549962d242a60542581b49c43be6eaccb7197f0 (diff) | |
download | trace-cmd-aaaaf69ba76310abfa150f48784006cd1079ccf8.tar.gz |
trace-cmd: Check the return of create_instance()
If create_instance() fails to allocate an instance, it returns NULL. Have the
callers check the return of create_instance() to make sure it succeeded and
report if it failed.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-cmd.c | 2 | ||||
-rw-r--r-- | trace-record.c | 10 | ||||
-rw-r--r-- | trace-stat.c | 2 |
3 files changed, 14 insertions, 0 deletions
diff --git a/trace-cmd.c b/trace-cmd.c index 4c5b564f..f6457859 100644 --- a/trace-cmd.c +++ b/trace-cmd.c @@ -532,6 +532,8 @@ int main (int argc, char **argv) die("Can only show one buffer at a time"); buffer = optarg; instance = create_instance(optarg); + if (!instance) + die("Failed to create instance"); break; case 'c': if (cpu) diff --git a/trace-record.c b/trace-record.c index 4b3dffea..a3ff6a33 100644 --- a/trace-record.c +++ b/trace-record.c @@ -358,6 +358,8 @@ static int __add_all_instances(const char *tracing_dir) free(instance_path); instance = create_instance(name); + if (!instance) + die("Failed to create instance"); add_instance(instance); } @@ -3924,6 +3926,8 @@ void trace_record (int argc, char **argv) break; case 'B': instance = create_instance(optarg); + if (!instance) + die("Failed to create instance"); add_instance(instance); break; case 'a': @@ -3955,6 +3959,8 @@ void trace_record (int argc, char **argv) break; case 'B': instance = create_instance(optarg); + if (!instance) + die("Failed to create instance"); add_instance(instance); break; case 'a': @@ -4002,6 +4008,8 @@ void trace_record (int argc, char **argv) case 'B': last_specified_all = 0; instance = create_instance(optarg); + if (!instance) + die("Failed to create instance"); add_instance(instance); /* -d will remove keep */ instance->keep = 1; @@ -4262,6 +4270,8 @@ void trace_record (int argc, char **argv) break; case 'B': instance = create_instance(optarg); + if (!instance) + die("Failed to create instance"); add_instance(instance); if (profile) instance->profile = 1; diff --git a/trace-stat.c b/trace-stat.c index 4d96b025..0f1610ec 100644 --- a/trace-stat.c +++ b/trace-stat.c @@ -902,6 +902,8 @@ void trace_stat (int argc, char **argv) break; case 'B': instance = create_instance(optarg); + if (!instance) + die("Failed to create instance"); add_instance(instance); /* top instance requires direct access */ if (!topt && is_top_instance(first_instance)) |