Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752748AbdFTJY0 (ORCPT ); Tue, 20 Jun 2017 05:24:26 -0400 Received: from terminus.zytor.com ([65.50.211.136]:43231 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbdFTJJt (ORCPT ); Tue, 20 Jun 2017 05:09:49 -0400 Date: Tue, 20 Jun 2017 02:07:35 -0700 From: tip-bot for Taeung Song Message-ID: Cc: treeze.taeung@gmail.com, mingo@kernel.org, jolsa@kernel.org, hpa@zytor.com, namhyung@kernel.org, acme@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, acme@redhat.com, namhyung@kernel.org, hpa@zytor.com, jolsa@kernel.org, mingo@kernel.org, treeze.taeung@gmail.com In-Reply-To: <1497671197-20450-1-git-send-email-treeze.taeung@gmail.com> References: <1497671197-20450-1-git-send-email-treeze.taeung@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf config: Check error cases of {show_spec, set}_config() Git-Commit-ID: 4f1fd74283582f3f5c34d1c9ed55117d775b4a20 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1711 Lines: 54 Commit-ID: 4f1fd74283582f3f5c34d1c9ed55117d775b4a20 Gitweb: http://git.kernel.org/tip/4f1fd74283582f3f5c34d1c9ed55117d775b4a20 Author: Taeung Song AuthorDate: Sat, 17 Jun 2017 12:46:37 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 19 Jun 2017 22:05:54 -0300 perf config: Check error cases of {show_spec, set}_config() 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 Signed-off-by: Taeung Song Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/1497671197-20450-1-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-config.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index 7545966..bb1be79 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c @@ -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); } }