From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B63B8C001B0 for ; Fri, 11 Aug 2023 02:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233083AbjHKCPz (ORCPT ); Thu, 10 Aug 2023 22:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbjHKCPy (ORCPT ); Thu, 10 Aug 2023 22:15:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB17726A0 for ; Thu, 10 Aug 2023 19:15:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6E0736294C for ; Fri, 11 Aug 2023 02:15:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26BACC433C7; Fri, 11 Aug 2023 02:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691720152; bh=LIlQtLbvm5w/WB8aaUqKdtrk5OeIAXfmw6wC7KM1ZUM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CJDBhI/9vosasA4VInT3HhktogHJLRWwztSEeaGvEGUu3+QeUn1wB482KZG5FU4pF GyxqfqnAC3QIl1GKTD9pmTWPIeRVtnwGHX/Bsauz/iiGPP+HZEy3TaBy6vbYM2BYEY ur8YOul/U98RoVHycMJg/9VjmKARNRN1/iZmGAzrWWgaNNWZ1gborZTtpmzHav8ujB +lgw7yktro0W9TgduCSiRsXMATe1J7xdUo4qa0mUqKjiC82AGIEZrvXY8iyIrgSt1z hag6E9dy9BtA4t1DDuOmWyPC50z3u+tvbODnWHZYxFBFkLpwaX+HXpJandVSxLLj+s w0+IHgUV20vWg== Date: Fri, 11 Aug 2023 11:15:48 +0900 From: Masami Hiramatsu (Google) To: Arnaldo Carvalho de Melo Cc: Adrian Hunter , Ian Rogers , Jiri Olsa , Namhyung Kim , Linux Kernel Mailing List Subject: Re: [PATCH 1/1] perf probe: Free string returned by synthesize_perf_probe_point() on failure in synthesize_perf_probe_command() Message-Id: <20230811111548.227d9fb19f2540a3c6bb5273@kernel.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 4 Aug 2023 13:26:54 -0300 Arnaldo Carvalho de Melo wrote: > Building perf with EXTRA_CFLAGS="-fsanitize=address" a leak was detected > elsewhere and lead to an audit, where we found that > synthesize_perf_probe_command() may leak synthesize_perf_probe_point() > return on failure, fix it. This looks good to me. Acked-by: Masami Hiramatsu (Google) Thanks, > > Cc: Adrian Hunter > Cc: Ian Rogers > Cc: Jiri Olsa > Cc: Masami Hiramatsu > Cc: Namhyung Kim > Link: https://lore.kernel.org/lkml/ > Signed-off-by: Arnaldo Carvalho de Melo > --- > tools/perf/util/probe-event.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c > index c7bfeab610a3679a..2835d87cb97771f9 100644 > --- a/tools/perf/util/probe-event.c > +++ b/tools/perf/util/probe-event.c > @@ -2063,14 +2063,18 @@ char *synthesize_perf_probe_command(struct perf_probe_event *pev) > goto out; > > tmp = synthesize_perf_probe_point(&pev->point); > - if (!tmp || strbuf_addstr(&buf, tmp) < 0) > + if (!tmp || strbuf_addstr(&buf, tmp) < 0) { > + free(tmp); > goto out; > + } > free(tmp); > > for (i = 0; i < pev->nargs; i++) { > tmp = synthesize_perf_probe_arg(pev->args + i); > - if (!tmp || strbuf_addf(&buf, " %s", tmp) < 0) > + if (!tmp || strbuf_addf(&buf, " %s", tmp) < 0) { > + free(tmp); > goto out; > + } > free(tmp); > } > > -- > 2.37.1 > -- Masami Hiramatsu (Google)