Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbdFQDqo (ORCPT ); Fri, 16 Jun 2017 23:46:44 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:32951 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391AbdFQDqm (ORCPT ); Fri, 16 Jun 2017 23:46:42 -0400 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim Subject: [PATCH v4 1/5] perf config: Check error cases of {show_spec, set}_config() Date: Sat, 17 Jun 2017 12:46:37 +0900 Message-Id: <1497671197-20450-1-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1186 Lines: 44 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 Cc: Jiri Olsa Cc: Namhyung Kim Signed-off-by: Taeung Song --- 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); } } -- 2.7.4