Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1457381rdg; Sat, 12 Aug 2023 01:55:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQgEVOpSDam8bdmjQELHnPKr3fR6wxHNnNyxhr20fF4ljwKoNP7pZ9GVwtMWLgSoMhZqrn X-Received: by 2002:a17:907:1dea:b0:99d:9a14:4f1b with SMTP id og42-20020a1709071dea00b0099d9a144f1bmr92166ejc.55.1691830513135; Sat, 12 Aug 2023 01:55:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691830513; cv=none; d=google.com; s=arc-20160816; b=XbjVELc0dxghPkYUTouJLsavtdx0/zod45VlNXyBM866CVURA2a/sRvhB/qxUQ2/zB uJQ2JK/uEq+ZCLTmKEcf6VK7ApG4DMKYo/cDGUojMrz/ZQ5fMwJL6WmEimP3aNqkSFkg Ls3+YJonfAalVsSE/r0Nl0ihD5K4QJOlaIIY2V6td0966/qttN7wk+4JjQ5j4WgeMLLa nRAvz3HkXY2HR473Ba61sqfLvprNfcwWxXcxvbHrkGr2IvuSXxe9Zq2s/ioQcc1OQMtj 4JCmZh5pD6PQxDtLZ+nh2+O/r7/kJ6BQN6fmPU8wspouSVjNftiMUKgkHobZ97jnn8rQ KBCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fjyk1dDB1vhlay9Gbq2Ed2kiTxQMPSYFDY+F3mjOTEI=; fh=yJzUIAXk3G9GFZhd7AEi53Yh6JaeRXiXWLsFmPRnLKo=; b=unumLRgBCeRCuuRoTNpOxXxPO4dqMYQ73C3SHWlGJQ0xWxQIwneYF5iNdfEbPEIFzX S2ywD9YhqzXBkiDwprgrBLq6WYU7fhw9/iGQYN9P90Q7h0LrpzlZjr/2HP+V6lWbJvbz qnulNiZ43hKyW9aXAuU0DBIuITAGOlUSF0QOoNWcQHtYdtNV2llqNbEmFCO91gVFlbEk 8ULz6kVeDUYLTDzv2OpBVXyPBsYhFTWjtZWzrVi99JMaY0tGd3g/M0uJOd4tlJcwew3q 3NkkaAhDWJY/NzEpBDoe7iFUrnCxYad7Fhs4ity22qg3nAsW4kU6yM2viXr9VY2+OnlM gF7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a13-20020a170906684d00b0099d9947ea10si146355ejs.166.2023.08.12.01.54.48; Sat, 12 Aug 2023 01:55:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236937AbjHLIwp (ORCPT + 99 others); Sat, 12 Aug 2023 04:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236086AbjHLIwD (ORCPT ); Sat, 12 Aug 2023 04:52:03 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 038072696; Sat, 12 Aug 2023 01:52:05 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RNDpP21LFztRQh; Sat, 12 Aug 2023 16:48:29 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 12 Aug 2023 16:52:00 +0800 From: Yang Jihong To: , , , , , , , , , , , , , CC: Subject: [RFC v1 01/16] perf kwork: Fix incorrect and missing free atom in work_push_atom() Date: Sat, 12 Aug 2023 08:49:02 +0000 Message-ID: <20230812084917.169338-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230812084917.169338-1-yangjihong1@huawei.com> References: <20230812084917.169338-1-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 1. Atoms are managed in page mode and should be released using atom_free() instead of free(). 2. When the event does not match, the atom needs to free. Fixes: f98919ec4fcc ("perf kwork: Implement 'report' subcommand") Signed-off-by: Yang Jihong --- tools/perf/builtin-kwork.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 14bf7a8429e7..73b5dc099a8a 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -406,12 +406,14 @@ static int work_push_atom(struct perf_kwork *kwork, work = work_findnew(&class->work_root, &key, &kwork->cmp_id); if (work == NULL) { - free(atom); + atom_free(atom); return -1; } - if (!profile_event_match(kwork, work, sample)) + if (!profile_event_match(kwork, work, sample)) { + atom_free(atom); return 0; + } if (dst_type < KWORK_TRACE_MAX) { dst_atom = list_last_entry_or_null(&work->atom_list[dst_type], -- 2.30.GIT