From nobody Sat Oct 3 03:53:11 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0670A346E7A; Wed, 5 Aug 2026 15:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785942660; cv=none; b=Ka3Pvo0yFQ4HbTV6KDviyB/51gClCIFG8JWxWEhmFH2++vNDlagyqMMbnRgfg7EpEqZvLuhUl8ZIRvisoqWdL95QMz3au4cZcHvNFlw64kfurSOYTh7VzlKP4hETZwzfLGYE9te/Th5vdfKXQGkzScsq+XG4qJ68s5IxL7elN5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785942660; c=relaxed/simple; bh=qJK/ewuynEsZcB86jq0MK1Vx/0GyjzBk2BNUN3w15fo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O9qPC6Tr88KChyVxZyIPFUWLYD4/7iB0ZJDLPsm4g5g6f47s9RIXp1XUd09vFQPtMCg+JCOYJIAcmkqpO2JcFtatGX/ahKarIkm1LupjRuRm5lNFzzvzQ8lFH7/8Dxc9M8ChyfnPeoijdOb3Gn2PeheMSzUGIn9vBG+MTfG0ar0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EA8OYctW; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EA8OYctW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7B331F00A3D; Wed, 5 Aug 2026 15:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785942658; bh=hajgRSCoDXi/OYysUPyK2mQy8Uhr7xOkmiwQoLuTItc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EA8OYctWW+VRr4t8Ulh2xnIx7jzsSAmKM2VVYAtguMqehdq/c9dPQir1tc/tHxsFy W1MvKe5hlaPVjdCj7Y3wotuG8HR90SeLA7Z9WQbtDnydJC76xWTEGatz/08C/uFV75 i8gnGsG2qeWaJneFBu31GP6RVlKFG8iTJJCYrqWKBBs8Kod/Sl8AyUpDChNtJccH1C +Z6EP0RiW1NF9POlP1z1r92Td9bIRvBNBMjDng/EmeVkSf7d4nyqcje+M4ja4z1qw5 sJrKroFfYzyga+b72eQ9/JS5+nHjUL3UTb+lWt1ByDGBiRNJA+JQ9RO6irHkcouZS4 KIM1FHZS+hmXg== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , James Clark , Jiri Olsa , Ian Rogers , Adrian Hunter , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , sashiko-bot Subject: [PATCH 1/2] perf c2c: Fix error masking, OOM, and unchecked caller errors in hpp_list__parse() Date: Wed, 5 Aug 2026 12:10:42 -0300 Message-ID: <20260805151043.237233-2-acme@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260805151043.237233-1-acme@kernel.org> References: <20260805151043.237233-1-acme@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnaldo Carvalho de Melo hpp_list__parse() has three bugs: 1. The PARSE_LIST macro resets ret =3D 0 at the start of each invocation, so an error from output parsing is silently overwritten when the sort parsing block runs. The function returns success with partially initialized state. 2. When the caller passes a non-NULL output_ or sort_ string, but strdup() returns NULL due to OOM, NULL is passed to PARSE_LIST which treats it as empty input (the "if (!_list) break" branch). No error is returned. 3. When the called _fn function fails and returns something other than -ESRCH or -EINVAL (-ENOMEM, for instance) it was not bailing out of the strtok loop. Fix them by checking strdup() return values before proceeding and adding a cleanup label so that ret from each PARSE_LIST call is checked before the next runs, preserving the first error. The early exits now skip perf_hpp__setup_output_field(), which means c2c_hists__reinit() can return a non-zero value in cases that previously always succeeded silently. Both callers discarded its return: resort_cl_cb() continued into hists__collapse_resort() on a broken list, and perf_c2c__report() proceeded with uninitialised hists. Fix the full chain: check and propagate the error in resort_cl_cb() -- hists__iterate_cb= () already stops iteration and returns the callback error -- and check both c2c_hists__reinit() and hists__iterate_cb() in perf_c2c__report(). Also turn PARSE_LIST into a function, using a switch to catch other errors, converting the called functions to return an appropriate errno instead of -1 on failure. Also make the two callers that iterate sort_dimension__add() and output_field_add() handle the newly propagated errors: setup_sort_list() and setup_output_list() only checked for -EINVAL and -ESRCH, so an -ENOMEM from a failed allocation was silently overwritten by the next loop iteration. Break out of the loop and propagate any other error. The hpp_list__parse() fixes were developed with AI assistance from Claude:claude-sonnet-4.6, and the setup_sort_list()/setup_output_list() caller fixes with AI assistance from Opencode:mimo-v2.5-free and Opencode:DeepSeek-V4-Flash-free. Fixes: 2d388bd0c9d3 ("perf c2c report: Add stdio output support") Reported-by: sashiko-bot Cc: Jiri Olsa Assisted-by: Claude:claude-sonnet-4.6 Assisted-by: Opencode:mimo-v2.5-free Assisted-by: Opencode:DeepSeek-V4-Flash-free Signed-off-by: Arnaldo Carvalho de Melo Reviewed-by: Ian Rogers --- tools/perf/builtin-c2c.c | 85 ++++++++++++++++++++++++++++------------ tools/perf/util/sort.c | 76 +++++++++++++++++++++++------------ 2 files changed, 112 insertions(+), 49 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index c9584dbedf77afe8..160b82694d391c50 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -12,11 +12,14 @@ */ #include #include +#include +#include =20 #include #include #include #include +#include #include #include #include @@ -2063,26 +2066,38 @@ static int c2c_hists__init_sort(struct perf_hpp_lis= t *hpp_list, char *name, stru return 0; } =20 -#define PARSE_LIST(_list, _fn) \ - do { \ - char *tmp, *tok; \ - ret =3D 0; \ - \ - if (!_list) \ - break; \ - \ - for (tok =3D strtok_r((char *)_list, ", ", &tmp); \ - tok; tok =3D strtok_r(NULL, ", ", &tmp)) { \ - ret =3D _fn(hpp_list, tok, env); \ - if (ret =3D=3D -EINVAL) { \ - pr_err("Invalid --fields key: `%s'", tok); \ - break; \ - } else if (ret =3D=3D -ESRCH) { \ - pr_err("Unknown --fields key: `%s'", tok); \ - break; \ - } \ - } \ - } while (0) +static int __hpp_list__parse(struct perf_hpp_list *hpp_list, char *_list, = struct perf_env *env, + int (*_fn)(struct perf_hpp_list *hpp_list, char *name, struct perf= _env *env)) +{ + char *tmp, *tok; + int ret =3D 0; + + if (!_list) + return 0; + + for (tok =3D strtok_r(_list, ", ", &tmp); tok; tok =3D strtok_r(NULL, ", = ", &tmp)) { + ret =3D _fn(hpp_list, tok, env); + switch (ret) { + case 0: + continue; + case -EINVAL: + pr_err("Invalid --fields key: `%s'", tok); + goto out; + case -ESRCH: + pr_err("Unknown --fields key: `%s'", tok); + goto out; + default: { + char buf[STRERR_BUFSIZE]; + + pr_err("%s for --fields key: `%s'", + str_error_r(-ret, buf, sizeof(buf)), tok); + goto out; + } + } + } +out: + return ret; +} =20 static int hpp_list__parse(struct perf_hpp_list *hpp_list, const char *output_, @@ -2093,8 +2108,18 @@ static int hpp_list__parse(struct perf_hpp_list *hpp= _list, char *sort =3D sort_ ? strdup(sort_) : NULL; int ret; =20 - PARSE_LIST(output, c2c_hists__init_output); - PARSE_LIST(sort, c2c_hists__init_sort); + /* strdup() returns NULL on OOM, don't silently treat as empty */ + if ((output_ && !output) || (sort_ && !sort)) { + ret =3D -ENOMEM; + goto out; + } + + ret =3D __hpp_list__parse(hpp_list, output, env, c2c_hists__init_output); + if (ret) + goto out; + ret =3D __hpp_list__parse(hpp_list, sort, env, c2c_hists__init_sort); + if (ret) + goto out; =20 /* copy sort keys to output fields */ perf_hpp__setup_output_field(hpp_list); @@ -2111,6 +2136,7 @@ static int hpp_list__parse(struct perf_hpp_list *hpp_= list, perf_hpp__append_sort_keys(&hists->list); #endif =20 +out: free(output); free(sort); return ret; @@ -2281,6 +2307,7 @@ static int resort_cl_cb(struct hist_entry *he, void *= arg) struct c2c_hist_entry *c2c_he; struct c2c_hists *c2c_hists; bool display =3D he__display(he, &c2c.shared_clines_stats); + int ret; =20 c2c_he =3D container_of(he, struct c2c_hist_entry, he); c2c_hists =3D c2c_he->hists; @@ -2291,7 +2318,9 @@ static int resort_cl_cb(struct hist_entry *he, void *= arg) c2c_he->cacheline_idx =3D idx++; calc_width(c2c_he); =20 - c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort, env); + ret =3D c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort, env); + if (ret) + return ret; =20 hists__collapse_resort(&c2c_hists->hists, NULL); hists__output_resort_cb(&c2c_hists->hists, NULL, filter_cb); @@ -3356,13 +3385,19 @@ static int perf_c2c__report(int argc, const char **= argv) else if (c2c.display =3D=3D DISPLAY_SNP_PEER) sort_str =3D "tot_peer"; =20 - c2c_hists__reinit(&c2c.hists, output_str, sort_str, perf_session__env(ses= sion)); + err =3D c2c_hists__reinit(&c2c.hists, output_str, sort_str, perf_session_= _env(session)); + if (err) { + pr_err("Failed to reinitialize hists\n"); + goto out_mem2node; + } =20 ui_progress__init(&prog, c2c.hists.hists.nr_entries, "Sorting..."); =20 hists__collapse_resort(&c2c.hists.hists, NULL); hists__output_resort_cb(&c2c.hists.hists, &prog, resort_shared_cl_cb); - hists__iterate_cb(&c2c.hists.hists, resort_cl_cb, perf_session__env(sessi= on)); + err =3D hists__iterate_cb(&c2c.hists.hists, resort_cl_cb, perf_session__e= nv(session)); + if (err) + goto out_mem2node; =20 ui_progress__finish(); =20 diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index dcf9189786f8aeba..58638ec9ae0ede7f 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -3105,7 +3105,7 @@ static int __sort_dimension__add_hpp_sort(struct sort= _dimension *sd, struct hpp_sort_entry *hse =3D __sort_dimension__alloc_hpp(sd, level); =20 if (hse =3D=3D NULL) - return -1; + return -ENOMEM; =20 perf_hpp_list__register_sort_field(list, &hse->hpp); return 0; @@ -3118,7 +3118,7 @@ static int __sort_dimension__add_hpp_output(struct so= rt_dimension *sd, struct hpp_sort_entry *hse =3D __sort_dimension__alloc_hpp(sd, level); =20 if (hse =3D=3D NULL) - return -1; + return -ENOMEM; =20 perf_hpp_list__column_register(list, &hse->hpp); return 0; @@ -3742,14 +3742,18 @@ static int __sort_dimension__add(struct sort_dimens= ion *sd, struct perf_hpp_list *list, int level) { + int ret; + if (sd->taken) return 0; =20 - if (__sort_dimension__add_hpp_sort(sd, list, level) < 0) - return -1; + ret =3D __sort_dimension__add_hpp_sort(sd, list, level); + if (ret < 0) + return ret; =20 - if (__sort_dimension__update(sd, list) < 0) - return -1; + ret =3D __sort_dimension__update(sd, list); + if (ret < 0) + return ret; =20 sd->taken =3D 1; =20 @@ -3767,7 +3771,7 @@ static int __hpp_dimension__add(struct hpp_dimension = *hd, =20 fmt =3D __hpp_dimension__alloc_hpp(hd, level); if (!fmt) - return -1; + return -ENOMEM; =20 hd->taken =3D 1; hd->was_taken =3D 1; @@ -3779,14 +3783,18 @@ static int __sort_dimension__add_output(struct perf= _hpp_list *list, struct sort_dimension *sd, int level) { + int ret; + if (sd->taken) return 0; =20 - if (__sort_dimension__add_hpp_output(sd, list, level) < 0) - return -1; + ret =3D __sort_dimension__add_hpp_output(sd, list, level); + if (ret < 0) + return ret; =20 - if (__sort_dimension__update(sd, list) < 0) - return -1; + ret =3D __sort_dimension__update(sd, list); + if (ret < 0) + return ret; =20 sd->taken =3D 1; return 0; @@ -3803,7 +3811,7 @@ static int __hpp_dimension__add_output(struct perf_hp= p_list *list, =20 fmt =3D __hpp_dimension__alloc_hpp(hd, level); if (!fmt) - return -1; + return -ENOMEM; =20 hd->taken =3D 1; perf_hpp_list__column_register(list, fmt); @@ -3869,8 +3877,7 @@ int sort_dimension__add(struct perf_hpp_list *list, c= onst char *tok, strlen(tok))) return -EINVAL; =20 - __sort_dimension__add(sd, list, level); - return 0; + return __sort_dimension__add(sd, list, level); } =20 for (i =3D 0; i < ARRAY_SIZE(memory_sort_dimensions); i++) { @@ -3882,8 +3889,7 @@ int sort_dimension__add(struct perf_hpp_list *list, c= onst char *tok, if (sort__mode !=3D SORT_MODE__MEMORY) return -EINVAL; =20 - __sort_dimension__add(sd, list, level); - return 0; + return __sort_dimension__add(sd, list, level); } =20 for (i =3D 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) { @@ -3973,15 +3979,25 @@ static int setup_sort_list(struct perf_hpp_list *li= st, char *str, } =20 ret =3D sort_dimension__add(list, tok, evlist, env, level); - if (ret =3D=3D -EINVAL) { + switch (ret) { + case 0: + break; + case -EINVAL: if (!cacheline_size() && !strncasecmp(tok, "dcacheline", strlen(tok))) ui__error("The \"dcacheline\" --sort key needs to know the cacheline = size and it couldn't be determined on this system"); else ui__error("Invalid --sort key: `%s'", tok); - break; - } else if (ret =3D=3D -ESRCH) { + goto out; + case -ESRCH: ui__error("Unknown --sort key: `%s'", tok); - break; + goto out; + default: { + char buf[STRERR_BUFSIZE]; + + ui__error("%s for --sort key: `%s'", + str_error_r(-ret, buf, sizeof(buf)), tok); + goto out; + } } prev_level =3D level; } @@ -3989,6 +4005,7 @@ static int setup_sort_list(struct perf_hpp_list *list= , char *str, level =3D next_level; } while (tmp); =20 +out: return ret; } =20 @@ -4315,15 +4332,26 @@ static int setup_output_list(struct perf_hpp_list *= list, char *str) for (tok =3D strtok_r(str, ", ", &tmp); tok; tok =3D strtok_r(NULL, ", ", &tmp)) { ret =3D output_field_add(list, tok, &level); - if (ret =3D=3D -EINVAL) { - ui__error("Invalid --fields key: `%s'", tok); + switch (ret) { + case 0: break; - } else if (ret =3D=3D -ESRCH) { + case -EINVAL: + ui__error("Invalid --fields key: `%s'", tok); + goto out; + case -ESRCH: ui__error("Unknown --fields key: `%s'", tok); - break; + goto out; + default: { + char buf[STRERR_BUFSIZE]; + + ui__error("%s for --fields key: `%s'", + str_error_r(-ret, buf, sizeof(buf)), tok); + goto out; + } } } =20 +out: return ret; } =20 --=20 2.55.0 From nobody Sat Oct 3 03:53:11 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FD55468C28; Wed, 5 Aug 2026 15:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785942665; cv=none; b=iE6fIDt6hkP2aBaEfhq24rQtTmarS+ZiuBG8+p9VTc0yQq/4ExLLt+ITo3WAa8FwT+firQvlC4oMg3PpKzKB394PCJDbVYT3VQvUC8yPxqx7sSfq65H0UR7eFNKBkfaG9mt4csp1hQhgMawGVUNJqGAbKwq/cPEBHyqB2OViMIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785942665; c=relaxed/simple; bh=ejjLZ7O65DcsPty9RAZL3PMR+obBOsqEbsgg2Tce320=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VUTgqvfatxgFu7OhZrV/CcF5GY17OuJCjual8TNcZguROUawSdovO9bC8B7tdUJvmPFqQh3OBYd6ufGmfWVaWgcxv8xf2Rde+vKs+Q2IA9LOSWxC5kQEKQCva7f5xq1dEELpG+aWjeQW99dauZFNLQA+dCJAGPVaGFF2vsdnSDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hqA5PR5Z; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hqA5PR5Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57E331F000E9; Wed, 5 Aug 2026 15:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785942663; bh=R/Qz7yDRFrAwuuEwAaKCqvsnfNtGCIPt8gEj0b125wo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hqA5PR5Z8PC8wC5o3OLR3i3BJWFZOkos05pneyKMsR5xN31ulOdU9d4SbDUSZNb7G XWJtS4dYaJshdmNhCUUEI65lcpzq/quoqwHxwB6xPPaNblIz3aFfD+k+UgQ5H+fvfU HMpwmkypsSw5yNxasodoEfd+kHJXG8FR5Bc2KThU0JyhoEASlss6DV4mYGjslX0cMC s3/D1TF5PQNeB2gzQsgeD4aIW6w1V20watBQk/5O6TQ5UyDSHiWR+IXJaSTs0Ade40 iJ0M3QXhPl/mVprekHG6oVviX0V7atNq7Hk9aLwmtnNumeZ4o0sUXKN3pq4LU0AbtE uX/0yyI1XJPvQ== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , James Clark , Jiri Olsa , Ian Rogers , Adrian Hunter , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , sashiko-bot Subject: [PATCH 2/2] perf c2c: Clean up registered formats on c2c_hists__init() and c2c_hists__reinit() failure Date: Wed, 5 Aug 2026 12:10:43 -0300 Message-ID: <20260805151043.237233-3-acme@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260805151043.237233-1-acme@kernel.org> References: <20260805151043.237233-1-acme@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnaldo Carvalho de Melo When c2c_hists__init() or c2c_hists__reinit() calls hpp_list__parse() and it fails partway through, format structures registered via perf_hpp_list__column_register() and perf_hpp_list__register_sort_field() are left on the hpp_list. In c2c_hists__init(), only one of the callers, c2c_he__alloc_hists(), handled this with perf_hpp__reset_output_field(), while perf_c2c_report() did not, leaking the partially registered entries. In c2c_hists__reinit(), neither perf_c2c_report() nor resort_cl_cb() clean up on failure. Fix by adding cleanup inside both functions themselves, so all callers are protected, and remove the now redundant reset in c2c_he__alloc_hists(). Fixes: 78b275437873 ("perf c2c report: Add sample processing") Reported-by: sashiko-bot Cc: Jiri Olsa Assisted-by: Claude:claude-opus-4.6 Assisted-by: Opencode:mimo-v2.5-free Assisted-by: Opencode:DeepSeek-V4-Flash-free Signed-off-by: Arnaldo Carvalho de Melo Reviewed-by: Ian Rogers --- tools/perf/builtin-c2c.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 160b82694d391c50..bc16a57e092742ad 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -229,7 +229,6 @@ he__get_c2c_hists(struct hist_entry *he, =20 ret =3D c2c_hists__init(hists, sort, nr_header_lines, env); if (ret) { - perf_hpp__reset_output_field(&hists->list); c2c_he->hists =3D NULL; free(hists); return NULL; @@ -2147,6 +2146,8 @@ static int c2c_hists__init(struct c2c_hists *hists, int nr_header_lines, struct perf_env *env) { + int ret; + __hists__init(&hists->hists, &hists->list); =20 /* @@ -2159,7 +2160,13 @@ static int c2c_hists__init(struct c2c_hists *hists, /* Overload number of header lines.*/ hists->list.nr_header_lines =3D nr_header_lines; =20 - return hpp_list__parse(&hists->list, /*output=3D*/NULL, sort, env); + ret =3D hpp_list__parse(&hists->list, /*output=3D*/NULL, sort, env); + + /* Unregister any formats added before the failure point */ + if (ret) + perf_hpp__reset_output_field(&hists->list); + + return ret; } =20 static int c2c_hists__reinit(struct c2c_hists *c2c_hists, @@ -2167,8 +2174,16 @@ static int c2c_hists__reinit(struct c2c_hists *c2c_h= ists, const char *sort, struct perf_env *env) { + int ret; + perf_hpp__reset_output_field(&c2c_hists->list); - return hpp_list__parse(&c2c_hists->list, output, sort, env); + ret =3D hpp_list__parse(&c2c_hists->list, output, sort, env); + + /* Unregister any formats added before the failure point */ + if (ret) + perf_hpp__reset_output_field(&c2c_hists->list); + + return ret; } =20 #define DISPLAY_LINE_LIMIT 0.001 --=20 2.55.0