Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2077024rdb; Mon, 9 Oct 2023 11:41:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyZkm3hdmvSaV8GHrKECvESiWHwGcoR4bN53ILtOPsUvB6o0pPArCqbLPFLrQJM1J41RlS X-Received: by 2002:a05:6a00:180c:b0:690:d008:8cfc with SMTP id y12-20020a056a00180c00b00690d0088cfcmr17501211pfa.32.1696876864895; Mon, 09 Oct 2023 11:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876864; cv=none; d=google.com; s=arc-20160816; b=NJjepslGHqV6JHR5N5GtPHCnfiTHZoGdr7cFbcxBrgarP7Fdaz1gw4vZgdN3nKGc7X ijZxPgil+zFUB5LkO4Ob2zNC+A/blndQSmn+r7i+nHFVpd4tj6bFCSlcOM+HRgZWmTs5 XsypwkWsRz48hH2KmWvC5//7KIR2edZ2qrBOMYidl8Lvtlv7FDrjL8wGxlzPM+M225Ls 34Vac4S5eGtBvbGu/huHe5+qSDeRE8z5LEPQwfinp3t8M11MLZrSFtDqGDDV9L+hVIeg d+aWphAGXuhzapZ9GRTNKytwDONWeKja5Vt5LMZrmryoCuRTzwh3jUirlTaz3TnoSAiW a0tw== 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=niI1DS8q+ZbexmAiDdLr0rnTr4377R73icOoozlTydQ=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=dluYnEM8RTHaxX6pmfstF4m+wKxmi2dp5O9LHdV7H5/EgFzJfaOa5weo/Zzjovr09X wFbWt01j7i7i6fUy5LhrUlSVdT2yfQg9myf0AHh4abSZfI8rkMSXTamO6DdOU9LYRc4Z Uj9LZ/bUSil/X93zvOw6DgVp0YtgLazq7+E9nRqLf5sJhPHu+8sAbLNnFgWdhexaYIKq B/g2jgM/J9aTfLzKxA2R1r9CI3YVnn16MCjkaEh9bKYU6ZzKE+VgPsY/EXiVSA84Hh2k +u++iy18zuMxTOUu2KYnJk32ha34A/IkMiB4a3TfVw/lzvFqLxlRFCub0mpvAZK8AiFw wAdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rXsOoCOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id cq24-20020a056a00331800b0068fba70d25dsi7738938pfb.33.2023.10.09.11.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:41:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rXsOoCOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 6115F8029A2B; Mon, 9 Oct 2023 11:40:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378109AbjJISkr (ORCPT + 99 others); Mon, 9 Oct 2023 14:40:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378311AbjJISkS (ORCPT ); Mon, 9 Oct 2023 14:40:18 -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 70F44E4 for ; Mon, 9 Oct 2023 11:40:00 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a23fed55d7so77429577b3.2 for ; Mon, 09 Oct 2023 11:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876799; x=1697481599; 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=niI1DS8q+ZbexmAiDdLr0rnTr4377R73icOoozlTydQ=; b=rXsOoCOi9IoLNymI/T09YYIpQk2fwalh+/sjgLoOz68oak642mvan2IHzdQ4lFkG9C qTDkmTDdRFdiOi/tIuqRosf8PTUh4R/3RDUMvBsPVFwqKrcElx4eB4/KGcZ4ugGHhR4q 6+UdrZ7knDyTRPrVQY5TysvxoGbDYKxYPyGtKLW7srpiDu8nTMdEH2p+ZHfgSkxck40k Q7QhWMoWIg1JlRT1FdvDOtxBJGgPOstnjpNtOD2cTbk8vRRZNFCw/x88Anev4FS7hmnI URIV8lpxbzse82ysu662VNHxzQnipW52Xfr2GyeANJmk93kdWXZjdBrMuq2jb91uxRjd g8Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876799; x=1697481599; 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=niI1DS8q+ZbexmAiDdLr0rnTr4377R73icOoozlTydQ=; b=WS8EAWMctc51mKpgf35EOhFlSNo4hIKOlEf02bZGibUi//ak+BMnqOoav3t8Og3N5H 4JGjMAwQDNDzdRTPyp9I6SyBwJDkE8FGvRwaeaOtWJDpmajh0p7QcUrkpOAKa7c+tdXR 83xkZ8eFb9/YffyPglA45OGyts7tDx+AjGWgeudKGo9TTZx3f3c9F+klSPqx5ppZ0gwi 2AJgV6XnSBBNAkpcb4F9ZLhVStkkAw1+xxEJyPhHjwXOHI+M0B9awrHgBi5vXfkwQhGK SS02XG34gSu5xQ0kJHgRalXEdG6GvHDo5UPQlGpGZFKhxvXC+jLNSVuREnqzd5SirD/N VCVw== X-Gm-Message-State: AOJu0YxF2hauZn6trJQBv2ZWpK7d1zkS5oVyNFGkdTBCsOfOWDHJAk11 74SSVM+U+wMkzHFImACgOclGFZRi+A6z X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a25:bcd:0:b0:d7f:2cb6:7d8c with SMTP id 196-20020a250bcd000000b00d7f2cb67d8cmr247211ybl.13.1696876799415; Mon, 09 Oct 2023 11:39:59 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:15 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-15-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 13/18] perf lock: Fix a memory leak on an error path 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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:40:59 -0700 (PDT) If a memory allocation fails then the strdup-ed string needs freeing. Detected by clang-tidy. Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index fa7419978353..a3ff2f4edbaa 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -2478,6 +2478,7 @@ static int parse_call_stack(const struct option *opt __maybe_unused, const char entry = malloc(sizeof(*entry) + strlen(tok) + 1); if (entry == NULL) { pr_err("Memory allocation failure\n"); + free(s); return -1; } -- 2.42.0.609.gbb76f46606-goog