Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1913905rdb; Thu, 17 Aug 2023 06:01:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYWXkXh0LqqXzDkvcbmNRulVnU2deMHdPZ4/ftzFxtvepxeNOe4NUq+IXoRmsH0wOxzrAd X-Received: by 2002:a05:6a21:66c5:b0:133:e3e3:dc07 with SMTP id ze5-20020a056a2166c500b00133e3e3dc07mr5690888pzb.49.1692277282168; Thu, 17 Aug 2023 06:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692277282; cv=none; d=google.com; s=arc-20160816; b=czQrziMOBiwG+BGaH7eF18YwFb5v2vHE0Nj8VF0E7uRNRC2e6NAzMu71Oh8aSoK//z yf5Hq1mw9sT1DhZmKWm/ERDf0y1uOBP00wlEFtX/0p/zp1YjTW/DbMeKfgod7Cw4pG0S 67wz8BpBU5r4kdLVuf5AiYkTTXObOBtMg+bbmzEqlFG3VgAf1q/27M7E3Loq1iVGCFxw mekb8eIhdZUWRtOm6J5Ofymo/mXdn3s0ej6Q8i/f1Hvyxdrs4waYmoZiHTDYfch2Q1w8 OtopWUF58JSUfHtebuMUstLfj/rvEeiuwRXJWEsdmOJva77Z4thUx4FdmcyenpaJiK3e Vlqg== 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 :message-id:date:subject:cc:to:from; bh=bzKfCh7LBWQ4LYpJj6pKM98uy7KVr/xLzBawlbqG6cY=; fh=c0mppflbHI55Cqe6+fupnHhfi9PatkfL7BQsysBCHko=; b=sGsUrwRI/DMrf/d+DRinaZllxJ1GNDp3p0XV74ytEPW1Rn8z9Pks91+S4h6b11VcGD d9t7ipHYRznWy4Fzl5Nky0aSdrAvlXoVjqortzuyLcrDviR85zhX7vhtJHLSijX+Dpwj Y/j6ZWnhD0wIYK7dEGyv3UdNPGwNKeusnXwTGhJjx6WjdGbCjmIDwL/oPTzVf/c3b6Gf qmUG3/oVUR12MzUTparR2bReLmEsJeEK5gDCpcdk5VtIoUwaWrlXmpd2AU0pXUZFIpIW PwTAufjVm1WrjYpCCcISdxpiR1Y+Njm/j/v3SkIRFpi4ORtX4vL4LRO2EeVnoJdwaTev K2JA== 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 k28-20020a637b5c000000b00565f42b81b2si3181195pgn.162.2023.08.17.06.01.03; Thu, 17 Aug 2023 06:01:22 -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 S1350575AbjHQMAZ (ORCPT + 99 others); Thu, 17 Aug 2023 08:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350563AbjHQL74 (ORCPT ); Thu, 17 Aug 2023 07:59:56 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02C892133 for ; Thu, 17 Aug 2023 04:59:54 -0700 (PDT) Received: from lhrpeml500004.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RRNkB001Dz6J6ZG; Thu, 17 Aug 2023 19:55:45 +0800 (CST) Received: from mscphis00759.huawei.com (10.123.66.134) by lhrpeml500004.china.huawei.com (7.191.163.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 17 Aug 2023 12:59:51 +0100 From: Konstantin Meskhidze To: CC: , , , , , , Subject: [PATCH] drivers: nvdimm: fix memleak Date: Thu, 17 Aug 2023 19:59:45 +0800 Message-ID: <20230817115945.771826-1-konstantin.meskhidze@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.123.66.134] X-ClientProxiedBy: mscpeml100001.china.huawei.com (7.188.26.227) To lhrpeml500004.china.huawei.com (7.191.163.9) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,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 Memory pointed by 'nd_pmu->pmu.attr_groups' is allocated in function 'register_nvdimm_pmu' and is lost after 'kfree(nd_pmu)' call in function 'unregister_nvdimm_pmu'. Co-developed-by: Ivanov Mikhail Signed-off-by: Konstantin Meskhidze --- drivers/nvdimm/nd_perf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvdimm/nd_perf.c b/drivers/nvdimm/nd_perf.c index 433bbb68a..14881c4e0 100644 --- a/drivers/nvdimm/nd_perf.c +++ b/drivers/nvdimm/nd_perf.c @@ -323,7 +323,8 @@ EXPORT_SYMBOL_GPL(register_nvdimm_pmu); void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu) { perf_pmu_unregister(&nd_pmu->pmu); nvdimm_pmu_free_hotplug_memory(nd_pmu); + kfree(nd_pmu->pmu.attr_groups); kfree(nd_pmu); } EXPORT_SYMBOL_GPL(unregister_nvdimm_pmu); -- 2.34.1