From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 195C1C433DF for ; Thu, 20 Aug 2020 02:17:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAD4E2078B for ; Thu, 20 Aug 2020 02:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726823AbgHTCR2 (ORCPT ); Wed, 19 Aug 2020 22:17:28 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9853 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726435AbgHTCR1 (ORCPT ); Wed, 19 Aug 2020 22:17:27 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 8D4DB9D049F6803AC068; Thu, 20 Aug 2020 10:17:25 +0800 (CST) Received: from DESKTOP-C3MD9UG.china.huawei.com (10.174.177.253) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Thu, 20 Aug 2020 10:17:15 +0800 From: Zhen Lei To: Oliver O'Halloran , Dan Williams , Vishal Verma , "Dave Jiang" , Ira Weiny , Markus Elfring , linux-nvdimm , linux-kernel CC: Zhen Lei Subject: [PATCH v3 1/7] libnvdimm: fix memory leaks in of_pmem.c Date: Thu, 20 Aug 2020 10:16:35 +0800 Message-ID: <20200820021641.3188-2-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200820021641.3188-1-thunder.leizhen@huawei.com> References: <20200820021641.3188-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.177.253] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, in the last error path of of_pmem_region_probe() and in of_pmem_region_remove(), free the memory allocated by kstrdup() is missing. Add kfree(priv->bus_desc.provider_name) to fix it. Fixes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus provider") Signed-off-by: Zhen Lei Reviewed-by: Oliver O'Halloran --- drivers/nvdimm/of_pmem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c index 10dbdcdfb9ce913..1292ffca7b2ecc0 100644 --- a/drivers/nvdimm/of_pmem.c +++ b/drivers/nvdimm/of_pmem.c @@ -36,6 +36,7 @@ static int of_pmem_region_probe(struct platform_device *pdev) priv->bus = bus = nvdimm_bus_register(&pdev->dev, &priv->bus_desc); if (!bus) { + kfree(priv->bus_desc.provider_name); kfree(priv); return -ENODEV; } @@ -83,6 +84,7 @@ static int of_pmem_region_remove(struct platform_device *pdev) struct of_pmem_private *priv = platform_get_drvdata(pdev); nvdimm_bus_unregister(priv->bus); + kfree(priv->bus_desc.provider_name); kfree(priv); return 0; -- 1.8.3