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 03C17C61DF4 for ; Fri, 24 Nov 2023 09:56:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345410AbjKXJzz (ORCPT ); Fri, 24 Nov 2023 04:55:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230347AbjKXJze (ORCPT ); Fri, 24 Nov 2023 04:55:34 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76A87D59; Fri, 24 Nov 2023 01:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sZ2n5kJr0I8EW9IHtq/ppoCQzkJzXCFITxFVQG51leA=; b=UrY8nM7tzzYrO+J1quhqWmDI62 a4qKLYgw0nxQI9wq9hdcvc8bEMvs+BEWQdT1ffr7xcwsXmSDZQ4XJ+nJ7kC7g+F1fsWOJYigUy1Uy 5ACkjxB0q9mz1QPtTG43GmvCD2BUubBdfRTEGagnnCDFeIMBESQXJXAv0s0ONNcKeGOUV1ZYv3lT1 8u6KRlqCbMjmN8lNk5X4lUQnJ9qeqVadq5LoIn6qdbZtJe2zyGfMbCOd3bm84ukjZHcrZOxQ4fUd3 qHt8jlB5zgMV1XsUcJv64sT6iWBLNHx/dCPuFqQSmAYUfwzUYVmKy/1dh0f5mF+8La9uq5lbpSCf4 IfNqdqqw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1r6SsC-00Dpus-27; Fri, 24 Nov 2023 09:55:21 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 045F1300134; Fri, 24 Nov 2023 10:53:20 +0100 (CET) Date: Fri, 24 Nov 2023 10:53:19 +0100 From: Peter Zijlstra To: zhaimingbing Cc: Namhyung Kim , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Sean Christopherson , Li Dong , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf lock: Fix a memory leak on an error path Message-ID: <20231124095319.GN3818@noisy.programming.kicks-ass.net> References: <20231124092657.10392-1-zhaimingbing@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231124092657.10392-1-zhaimingbing@cmss.chinamobile.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 24, 2023 at 05:26:57PM +0800, zhaimingbing wrote: > if a strdup-ed string is NULL,the allocated memory needs freeing. > > Signed-off-by: zhaimingbing > --- > tools/perf/builtin-lock.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c > index b141f2134..086041bcb 100644 > --- a/tools/perf/builtin-lock.c > +++ b/tools/perf/builtin-lock.c > @@ -2228,8 +2228,10 @@ static int __cmd_record(int argc, const char **argv) > else > ev_name = strdup(contention_tracepoints[j].name); > > - if (!ev_name) > + if (!ev_name) { > + free(rec_argv); > return -ENOMEM; > + } Isn't this an error path straight into exit?