Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2077137rdb; Mon, 9 Oct 2023 11:41:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGU7ENNJCcpTCOd+LYnYGbfQb6fkk6vQDu+ArlRRcPiYEU4JuCB90m9xyfV+76NV4RtukOd X-Received: by 2002:a17:90a:3f16:b0:279:354b:50f1 with SMTP id l22-20020a17090a3f1600b00279354b50f1mr13987826pjc.3.1696876875977; Mon, 09 Oct 2023 11:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876875; cv=none; d=google.com; s=arc-20160816; b=hCpFpNvfLLbC5kFYc8dmXjpXrTBMBcP98v9VmH773BPfEnoMuFNq4mCudWWRWFOp9O I56Hd9xxeCIfkyilTbhrFsiEIYjtAXBVOH4HEP/kXDi8aIBDVtM71rpwOF5lKMVHUAqa yAYoyr/cyBeof/Yhhquxxl3P2hrXbMkqX0jg/etWoxALLyIfJ2Nn8ZhPakt0TZ0Oi0EW L+Tk1U42TBwhfM1EZ5TpLIK/NlSi98NVbCnr+Oc4r1oyVCC3XCoEDM+6TtONRp2ZJzmq o6X1+jYj2YejUiU/O2e8GbeONaYSYawOgFCwKzNb2DKRwldXteYD3vo/oMRDTV9XkVgd bKrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=HGxcidzGPRegna1u1K7BT077Nrlph2dhlmMJs3FQauY=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=my/fgcrcQ0TAGjG+ocy1dJLdb4JqY9Twdq/uhv2eHFerg5qm3H2iUBk934YGKIcdP0 welnk8z+u/ELxcP1BZc0uSVwFGdldjGo4Bb1gEwByQPj9JGi2ikLlkOSoDrV5n5tSqJi RYONhjxpIsWd0JSVV37p3WHa8vhi1gVHuO3BcnMyJ6Q0GJAKJriY21s0lhpMRlgBJ11a NyX1yZ/m50TwJu2yiLy7AE07SZ+r8PDWja3ngn2+QzBXTMU2FfolWRhNAkByHxre97jW ButPpuV36sZfaP18tI286URasnDjUUa91dAxA7E28XwhZr5ntMSiuRBLAhgWoEEMzNYI uPlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=06hv2eld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id m1-20020a17090aab0100b00277507e8085si11485655pjq.55.2023.10.09.11.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=06hv2eld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 537AC8038B13; Mon, 9 Oct 2023 11:41:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378407AbjJISkv (ORCPT + 99 others); Mon, 9 Oct 2023 14:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378420AbjJISkT (ORCPT ); Mon, 9 Oct 2023 14:40:19 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83E56D4E for ; Mon, 9 Oct 2023 11:40:02 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59f8188b718so77598497b3.1 for ; Mon, 09 Oct 2023 11:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876801; x=1697481601; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=HGxcidzGPRegna1u1K7BT077Nrlph2dhlmMJs3FQauY=; b=06hv2eld/xw44RWn1xr2U+JITsXhvfwVgHKkxYlHPQ2wasN7Ofou0pUc3CoXr40ImG qNR2LlZ8MvLg6cNPhr9P2c7dmwXgQmo9Nnfc1/DUy85azjOubC+p31Q14GZ0G9/Vtg+Z oPc8KxwtQcwOMXO6VFfVwWcDpeHCbd/2jOTjXg4xDBWzuMNHHXT4X09J9e3vpQlqh5MV gawWuoboJtTEerxO9qEZqgXvGwMXiZG6mxTFVkgdreC+sNzfqDhtevV1bD3L+k2gV1D7 hyx4Ztm9+4LmZC7Ccs/auboXubItxm4aE+XkD0rkoHIcBeuLWs6ngFRxTVMMtRxuSmPh cQCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876801; x=1697481601; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HGxcidzGPRegna1u1K7BT077Nrlph2dhlmMJs3FQauY=; b=mIQeR7oxQ7DcshkmECyEOAc/WmMfiIkU3rYKSO6l1RqctdDHSCu15oeKgDWE2iYYng OjjddXHA2ns+XLFFU+XSo8bqr9XU1A2kNRgeohL8quY8TlyqRJC1ekqp/lMPESWfCJE7 FVODv0aJUDfXwiDvmsEjGTl9KTCm+jfYmpWQjUQOgL3NuJmTiQDYP3br7JPWV0oaIcR8 VHZuIgPJ48h5r1kNUGrA4ZVNCNUctRHJqt5L++FKrNu34kmAdQeIvyAZZGq+pAhAEBKW Dw5ddRlpKpXJMz3TA87Q+Ws1z3zpFgXfTBAKv5JrpTCzQGhKPJTmlkc0b///POuNhuni g0cA== X-Gm-Message-State: AOJu0YztZ8iBr2cnzSVFSoJRz+7ydOgrEC/GSn+t0N3UDAecEZf3AUuv O46ZPHhzXv4drwtursQd49QZogzYredv X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a81:a849:0:b0:577:619e:d3c9 with SMTP id f70-20020a81a849000000b00577619ed3c9mr336831ywh.10.1696876801567; Mon, 09 Oct 2023 11:40:01 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:16 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-16-irogers@google.com> Mime-Version: 1.0 References: <20231009183920.200859-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v3 14/18] perf parse-events: Fix unlikely memory leak when cloning terms From: Ian Rogers To: Nathan Chancellor , Nick Desaulniers , Tom Rix , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Yang Jihong , Huacai Chen , Ming Wang , Kan Liang , Ravi Bangoria , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:41:11 -0700 (PDT) Add missing free on an error path as detected by clang-tidy. Signed-off-by: Ian Rogers --- tools/perf/util/parse-events.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index c56e07bd7dd6..23c027cf20ae 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2549,8 +2549,10 @@ int parse_events_term__clone(struct parse_events_term **new, return new_term(new, &temp, /*str=*/NULL, term->val.num); str = strdup(term->val.str); - if (!str) + if (!str) { + zfree(&temp.config); return -ENOMEM; + } return new_term(new, &temp, str, /*num=*/0); } -- 2.42.0.609.gbb76f46606-goog