From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758818AbaGYBcD (ORCPT ); Thu, 24 Jul 2014 21:32:03 -0400 Received: from lgeamrelo02.lge.com ([156.147.1.126]:44394 "EHLO lgeamrelo02.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758296AbaGYBcA (ORCPT ); Thu, 24 Jul 2014 21:32:00 -0400 X-Original-SENDERIP: 10.177.220.181 X-Original-MAILFROM: namhyung@kernel.org From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Ingo Molnar , Paul Mackerras , Namhyung Kim , Namhyung Kim , LKML , Jiri Olsa , David Ahern , Minchan Kim Subject: [PATCH 2/2] perf tools: Check validity of --symfs value Date: Fri, 25 Jul 2014 10:31:48 +0900 Message-Id: <1406251908-8195-2-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1406251908-8195-1-git-send-email-namhyung@kernel.org> References: <1406251908-8195-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a symfs is given by user, it needs to be checked before applying. Currently, it just uses it even if realpath() failed. I guess it's because it needed to handle empty symfs which is the default value. But now it's only called when it's not empty so it'd be better to check before using it and warn users if failed. Cc: Minchan Kim Signed-off-by: Namhyung Kim --- tools/perf/util/symbol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 90723a12e947..95186185c1d5 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1864,8 +1864,11 @@ int symbol__init(void) if (*symbol_conf.symfs) { symfs = realpath(symbol_conf.symfs, NULL); - if (symfs == NULL) - symfs = (char *)symbol_conf.symfs; + if (symfs == NULL) { + pr_err("cannot apply symfs: %s: %s\n", + symbol_conf.symfs, strerror(errno)); + return -1; + } /* * A path to symbols of "/" is identical to "" -- 2.0.0