perf unwind: Handle allocation failure in libdw__get_entries()

Check the return value of zalloc() before dereferencing the allocated
dwfl_ui_ti structure.

Return -ENOMEM when the allocation fails to avoid a NULL pointer
dereference.

Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Triet Hoang 2026-08-18 14:48:37 +00:00 committed by Arnaldo Carvalho de Melo
parent 024b219744
commit aa18964dd6

View File

@ -397,6 +397,11 @@ int libdw__get_entries(unwind_entry_cb_t cb, void *arg,
dwfl = dwfl_ui_ti->dwfl;
} else {
dwfl_ui_ti = zalloc(sizeof(*dwfl_ui_ti));
if (!dwfl_ui_ti) {
free(ui);
return -ENOMEM;
}
dwfl = dwfl_begin(&offline_callbacks);
if (!dwfl)
goto out;