Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp2528438rdb; Fri, 18 Aug 2023 03:13:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2HZW2zli4Wn6pN0knjREptepQY0jpk8V4weCRR+tCKwrJnQLRrFAQBVsMzVYLV+XratU3 X-Received: by 2002:a05:6a20:441d:b0:13a:3bd6:2530 with SMTP id ce29-20020a056a20441d00b0013a3bd62530mr7794885pzb.1.1692353619862; Fri, 18 Aug 2023 03:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692353619; cv=none; d=google.com; s=arc-20160816; b=nM+dsLQjBRr8SXHcsX+TY7gjZScl0SuRlXuMha6RoYo49NdMg8rQ8txbIEwWP6sEGB 1Ilahjb8D+9H4A1/6imQzq/OuMBe7pBCDC6IOU+xSviAJ7PnqMNpXhLLj6I0NSAJR9Mu veGhmUIoq2jAJw8+9hu0rGt5xBtqf57DTRa51lubiV26r39gsDy76/rlI/CwnqpFabOR PmRgWRl/MNmjxAO8ZWME3PExZEXdv49lJwz6Nc2thzxQJixPwI4jDBsf2ijcKRjr530c z3GFumJGTXhfKrOOS6Vqh6LQ05bGVDqNaiSxJMzx8B2jSf0A/MMbVKJGpZfQ5jsY6ri9 w4sQ== 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=UEqe2MgkLZhqpiENy0pjfnw2rrIwFpUKFQe28fN2vLE=; fh=c0mppflbHI55Cqe6+fupnHhfi9PatkfL7BQsysBCHko=; b=L7qehyLUOpnLcWvlCyBzpeNe897WkAUavQHIt5auW3/V6uBKmBzXgwjHlmuGO7B+h9 Ty2jwttPrH97oe+bKY2iS5F30n4BuQ1KoilIrjRrz7+ocRAPItIFo55cONsTX6BAUFNE DGa3NFjQUUcEyxmkperMF2yId9aChPiHRsH58QKAnMvbP55sCQ5hX/PHsD/KeeXQpgQ4 jccspoQL1uDx7Mxn3SSSxwsBgUP1/Rab2LqtVEXbBcw3Z1krFfNZ0v08YQ8TQBUVgKMl 7PYPRc1HQBIrQUqiIMUrVPWthD3a1Tadd62bn2XYb6RaQdUvnA/bUd/HxKFZCf+YI6MO cKYw== 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 k64-20020a638443000000b0055adb191739si1209804pgd.62.2023.08.18.03.13.26; Fri, 18 Aug 2023 03:13:39 -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 S1350355AbjHQLla (ORCPT + 99 others); Thu, 17 Aug 2023 07:41:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350407AbjHQLlW (ORCPT ); Thu, 17 Aug 2023 07:41:22 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3C28E4F for ; Thu, 17 Aug 2023 04:41:21 -0700 (PDT) Received: from lhrpeml500004.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RRNJp31yhz6J6yC; Thu, 17 Aug 2023 19:37:14 +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:41:19 +0100 From: Konstantin Meskhidze To: CC: , , , , , , Subject: [PATCH] drivers: nvdimm: fix dereference after free Date: Thu, 17 Aug 2023 19:41:03 +0800 Message-ID: <20230817114103.754977-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: mscpeml500002.china.huawei.com (7.188.26.138) 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 'nd_pmu->pmu.attr_groups' is dereferenced in function 'nvdimm_pmu_free_hotplug_memory' call after it has been freed. Because in function 'nvdimm_pmu_free_hotplug_memory' memory pointed by the fields of 'nd_pmu->pmu.attr_groups' is deallocated it is necessary to call 'kfree' after 'nvdimm_pmu_free_hotplug_memory'. Co-developed-by: Ivanov Mikhail Signed-off-by: Konstantin Meskhidze --- drivers/nvdimm/nd_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvdimm/nd_perf.c b/drivers/nvdimm/nd_perf.c index 14881c4e0..2b6dc80d8 100644 --- a/drivers/nvdimm/nd_perf.c +++ b/drivers/nvdimm/nd_perf.c @@ -307,10 +307,10 @@ int register_nvdimm_pmu(struct nvdimm_pmu *nd_pmu, struct platform_device *pdev) } rc = perf_pmu_register(&nd_pmu->pmu, nd_pmu->pmu.name, -1); if (rc) { - kfree(nd_pmu->pmu.attr_groups); nvdimm_pmu_free_hotplug_memory(nd_pmu); + kfree(nd_pmu->pmu.attr_groups); return rc; } pr_info("%s NVDIMM performance monitor support registered\n", -- 2.34.1