[PATCH 2/2] perf tools: Check validity of --symfs value

From: Namhyung Kim
Date: Thu Jul 24 2014 - 21:32:09 EST


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 <minchan@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/