From nobody Thu Apr 9 18:57:14 2026 Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AB36366DAF; Fri, 6 Mar 2026 04:01:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772769702; cv=none; b=fEA6BlUkNUEHoLTspFpaywuvHxXIDhnyIKWPhoeWwtPSVfADPwOXR1KXPIxr+l/jgeZxQ5W0Div8bni5z6cAk1xIrLrd4uWGU0mNjhm+ep23kh4OwQLh6jw8A88ipYBEi7kkRogPoAxr7ahR7vANsiEd0J+Spq9D29AfztSxIAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772769702; c=relaxed/simple; bh=lbZ6nIyMaekUMThmpDClVgIo3f2kvIA/qK6y9kcf7Ns=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=qNvPgtJqLw9cVkDQOSVVWiKCuqpNXl7xpIwT8TRJpR+kHbf8brTLW0/7gJ3LkvCZXy8h9qkIcOgaXxacz9hevsUHhsd3NHPHSY//PCpQ31ahVnHelJTRMARZyvm0gy21exXVa8qost2BtlcNo+S8kbNBslMhZCIECNOxlo6KPDI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost (unknown [124.16.138.129]) by APP-03 (Coremail) with SMTP id rQCowABnTOOIUappPKDqCQ--.39045S2; Fri, 06 Mar 2026 12:01:12 +0800 (CST) From: Chen Ni To: linux-perf-users@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, james.clark@linaro.org, tianyou.li@intel.com, linux-kernel@vger.kernel.org, Chen Ni Subject: [PATCH v2] perf annotate: Fix hashmap__new() error checking Date: Fri, 6 Mar 2026 11:56:48 +0800 Message-Id: <20260306035648.1266660-1-nichen@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 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 X-CM-TRANSID: rQCowABnTOOIUappPKDqCQ--.39045S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Cw1fAF4fAF1fCw4DJr1xuFg_yoW8Jw1DpF 4DC3yxJ398JF45tw1ayFWfuF9xu3sxXr95GryFva1DZ3ySyrn5GrWSvryrKF4kZwsIq3W7 J3ZrKr4rAFWrCaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9K14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCY1x0262kKe7AKxVWUtVW8ZwCY02Avz4vE14v_Gryl42xK82IYc2Ij64vIr4 1l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK 67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI 8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAv wI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14 v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUeUDGUUUUU X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ Content-Type: text/plain; charset="utf-8" The hashmap__new() function never returns NULL, it returns error pointers. Fix the error checking to match. Additionally, set src->samples to NULL to prevent any later code from accidentally using the error pointer. Fixes: d3e7cad6f36d ("perf annotate: Add a hashmap for symbol histogram") Reviewed-by: Ian Rogers Signed-off-by: Chen Ni --- Changes in v2: - Set src->samples to NULL on error - Update commit message --- tools/perf/util/annotate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 2e3522905046..63f0ee9d4c03 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -44,6 +44,7 @@ #include "strbuf.h" #include #include +#include #include #include #include @@ -137,8 +138,10 @@ static int annotated_source__alloc_histograms(struct a= nnotated_source *src, return -1; =20 src->samples =3D hashmap__new(sym_hist_hash, sym_hist_equal, NULL); - if (src->samples =3D=3D NULL) + if (IS_ERR(src->samples)) { zfree(&src->histograms); + src->samples =3D NULL; + } =20 return src->histograms ? 0 : -1; } --=20 2.25.1