Skip to content

Commit

Permalink
perf config: Check error cases of {show_spec, set}_config()
Browse files Browse the repository at this point in the history
show_spec_config() and set_config() can be called multiple times
in the loop in cmd_config().

However, The error cases of them wasn't checked, so fix it.

Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1497671197-20450-1-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Taeung Song authored and Arnaldo Carvalho de Melo committed Jun 20, 2017
1 parent 1096c35 commit 4f1fd74
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tools/perf/builtin-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,23 @@ int cmd_config(int argc, const char **argv)
break;
}

if (value == NULL)
if (value == NULL) {
ret = show_spec_config(set, var);
else
if (ret < 0) {
pr_err("%s is not configured: %s\n",
var, config_filename);
free(arg);
break;
}
} else {
ret = set_config(set, config_filename, var, value);
if (ret < 0) {
pr_err("Failed to set '%s=%s' on %s\n",
var, value, config_filename);
free(arg);
break;
}
}
free(arg);
}
}
Expand Down

0 comments on commit 4f1fd74

Please sign in to comment.