perf buildid-cache: Fix use of uninitialized value

The buildid filename is first determined and then from this the
buildid read. If getting the filename fails then the buildid will be
used for a later memcmp uninitialized. Detected by clang-tidy.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: llvm@lists.linux.dev
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Tom Rix <trix@redhat.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20231009183920.200859-7-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
Ian Rogers 2023-10-09 11:39:07 -07:00 committed by Namhyung Kim
parent da0c884b07
commit 319d459898
1 changed files with 4 additions and 2 deletions

View File

@ -277,8 +277,10 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)
char filename[PATH_MAX];
struct build_id bid;
if (dso__build_id_filename(dso, filename, sizeof(filename), false) &&
filename__read_build_id(filename, &bid) == -1) {
if (!dso__build_id_filename(dso, filename, sizeof(filename), false))
return true;
if (filename__read_build_id(filename, &bid) == -1) {
if (errno == ENOENT)
return false;