Message ID | 1694715351-58279-1-git-send-email-lizhi.hou@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp543889vqi; Thu, 14 Sep 2023 11:30:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBzaRvvr00KeFIE8PqYbvrnMEvOGJdcVUpd0KVIBiBcc4VcqOloKjKRAGZv8ZieFJTgRDy X-Received: by 2002:a17:90b:4b48:b0:274:3d7d:e793 with SMTP id mi8-20020a17090b4b4800b002743d7de793mr6193919pjb.47.1694716255553; Thu, 14 Sep 2023 11:30:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694716255; cv=pass; d=google.com; s=arc-20160816; b=fM0EgDPyqX7pav2elxTGYUtEF7BXjwfssHBHFK0/mThxr4eV+RJxYza9QDw2rh1hze qoJ1iea9+88itq6ZXGNP1Zc2VANTMqQECtweJHn/pmuyTcMHSi2UGpUoVFaiI5O15FoB g89GWEsJbmYuYDsSUbIRR+ITN1m6UPUZjUz5zOOYhEbQR7Wx6rrmtKQfUYmflXO1TfPf gEAHAjTjdRYb/LULkpU9vpZvwFhM52B9jd+qaMgDZdT6kZ2vHDXfckvK4WiK3LlbEmgc yPU58+/FIfJ/8LqgPh0tiQQ7L/scSR47znXGx7S2GFIyBpAfZWMnSZI6svABEb8gMg79 4vOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=SifNL8ODpDDFEdAUcg7nM4MGe88oeZea6j9iF8opzVE=; fh=jTD81/nWUmH6ZBqLtbtF1nO5dWcjkwEN3azjd6TA0zA=; b=ZyNb4UHUACPI5W0ZYMQtA5WCahG9Er2jGo5rbOFxO5jCyKUtSDFsjwSK75LThz1BT+ mrgOVvYFvZcihL8ArR9pcIJOD28heJ3nQ9T6I3JisgNkiwP7xV8rXeZmQGKwn7zcQdTz Tu0uePUyM9hjDSc4/1ZMWPdX2cOx9l03D6hsmtbAU/lH4/iwkavRw7lRYqOxdmeXUvNG pDvpO9mIizE3+VJO+tAnvMF1w+vnkknqxIZd8tXohq4SBNEUtZbDMuLzmlDhW/9b+a8i XMDB71f5jlYvG5b3C8ZZOgR8l9OOaQLxljwF8PnaRpAlvWzmc00VreMjqvLQu+3oz08t C61g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0dH6UuO4; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id fw1-20020a17090b128100b0026d4415b926si4235105pjb.83.2023.09.14.11.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0dH6UuO4; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BD62D82295DB; Thu, 14 Sep 2023 11:16:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240873AbjINSQN (ORCPT <rfc822;pwkd43@gmail.com> + 33 others); Thu, 14 Sep 2023 14:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240824AbjINSQF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 14 Sep 2023 14:16:05 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2065.outbound.protection.outlook.com [40.107.92.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4FA71FFD; Thu, 14 Sep 2023 11:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A9TMWjLkFguhwsXODHC4KLgJTzyoZbAR24ZQBfO/Z0BFsAS2MR9hWALSWZ7K0zD0pzRLSrPVUSYwDhF/8FV7aZwzY8xA4o3iXh8BUiLOjvK+bBVmLg/AmwT32LATbnyU0akAhRDcTa7aNOv3y9I6mTAmNcUCQIzfXjVZ1L+3j7v6KEzvdBIPnDHqjXAyityiU4XPvRQ79TD7UEDmEBqGpgPJmHYnvDhSFAIxFOVca27ABN/H1weL30/Tfah1RcevvqwWDOV28ZNtEWKaqfZLlcwEO6k0SaDfwarUnGuTsGxJUdrvSewUfUzHPmKXUOMFQRTgi1nHT8JzA5Uh2ryJag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SifNL8ODpDDFEdAUcg7nM4MGe88oeZea6j9iF8opzVE=; b=fQIIdk/QCHZBBTilTnySU2aDtmxtVh6c8fJs1fCtDVNG5rd3teZ9L4qFIhqQPIInTyBlyptDUqa2VTlev10xBrdg0h2JCTzwWg2rLG7wbzqkI48F3K111iby184GxzkbbKe7mLSQEuZRNXGHdHRzboudNGinHmYhbbQQIRcnKnvjkuljWdJ04NLyJCx+TWUE2dpLk6mXJE5ZxoOLLhPkRGpYRkf0RhGF88jrESTdI4XDW0do3mQZ4KxHJIv5H0wjAUqlA6aZ7395aCSXq+H98ttQ4ag7iqw3/bo8Xw3CxLvpSJlFu5Zf+JjFKfHGg4eJ5++swY6oL1jtRNOvNwah9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SifNL8ODpDDFEdAUcg7nM4MGe88oeZea6j9iF8opzVE=; b=0dH6UuO4yPTXsCOxY2P26EqhP3v0Tfbq+X4RtwSoXr2c90P+OUv4GjBV7LclDf10lpuRtiEn5F9EMTC+qQXmG990hHpt9ikYh0oDu+S3IYghsOnaWjxTF+u0e0uBC8XvI4Yh9KU946qINgVfsMYK6c48I5I7l0cQtOOJXrk8b7Y= Received: from DM6PR18CA0009.namprd18.prod.outlook.com (2603:10b6:5:15b::22) by DM8PR12MB5399.namprd12.prod.outlook.com (2603:10b6:8:34::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Thu, 14 Sep 2023 18:15:58 +0000 Received: from DS2PEPF00003447.namprd04.prod.outlook.com (2603:10b6:5:15b:cafe::10) by DM6PR18CA0009.outlook.office365.com (2603:10b6:5:15b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Thu, 14 Sep 2023 18:15:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DS2PEPF00003447.mail.protection.outlook.com (10.167.17.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.20 via Frontend Transport; Thu, 14 Sep 2023 18:15:58 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 14 Sep 2023 13:15:57 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 14 Sep 2023 13:15:57 -0500 Received: from xsjlizhih40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 14 Sep 2023 13:15:56 -0500 From: Lizhi Hou <lizhi.hou@amd.com> To: <linux-pci@vger.kernel.org>, <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <herve.codina@bootlin.com> CC: Lizhi Hou <lizhi.hou@amd.com>, <bhelgaas@google.com>, <robh@kernel.org> Subject: [PATCH] PCI: of: Fix memory leak when of_changeset_create_node() failed Date: Thu, 14 Sep 2023 11:15:51 -0700 Message-ID: <1694715351-58279-1-git-send-email-lizhi.hou@amd.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003447:EE_|DM8PR12MB5399:EE_ X-MS-Office365-Filtering-Correlation-Id: 862b2080-7275-4fa2-b38f-08dbb54ea50a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t27ziNgipgt7B4351WWtOcvN0RkCFKrV+/tpMeSz7c3Udh9Mf4wVkPM010UE+6VThGyNLleX1y2o4K9RXlm1CSd9Hu8jN5MJlQSDMw/GHTdKOulGzD2bUdQBKgt4+NZwz9M/aAtnBOCk+y3w9l3YbNEED9f52AeSLlJf+WVoDVghRUpw6bB5Z/opqJ6cavy9b/ADLAgKsYlT9a/UpbxiQYDjX6udo5TurNmLAIjpHAmDCzzKCBvNsFCbbt0GCo3X8DYbJchgDqhSakpnoCjuy97NBTkSEOguwsWWtfxH4KyKQkl1UbtQ66zt02+yOCNzCobNb+OVgjzXIYrlKuSNT4sf6/c7bdeX87GbNKEf3KoecDZ4esAjcZRUMBa1rw9eiXxu7gbOfXY4AN7/tZOXfStWR+OeY3LcwHSPxyTLTAstFri7xXuLpafr6T3pJSlw0C4mHkaXJqK+z5FUrw4/m79AGGb4eBIRThqjN1jHcaGUH13PW/ojHBIyN8ZAjnH1zsmtl36bXqVX9rln2H24yXxPV1CgEbh6vfb5sXuQcttGL2em/rkI/JVnCvewqJs5a0jkTi5EdauRHfQspkwcjWp2Eop1R0+ysinl2sQtu8mHpvyp4IyqNV8/tn7/ZVOK3Y4KYg0ypEUeBnZPyeIt5Co++9Pr8Wgu/GsawbkyJv8MGgGFPaEGUUmR2+61tL81GJZCFlKYSRt0xkCJclwzNWZuj3PPtSJILjbkikPHI8eeJHFi+rOmyd4YP9/ECviqcHRFoJQlXRVQmR8yDZa1Vg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(346002)(376002)(39860400002)(396003)(186009)(451199024)(1800799009)(82310400011)(46966006)(36840700001)(40470700004)(44832011)(36860700001)(4744005)(83380400001)(356005)(6666004)(4326008)(426003)(86362001)(8676002)(336012)(8936002)(5660300002)(47076005)(2906002)(26005)(54906003)(110136005)(70206006)(70586007)(40480700001)(478600001)(82740400003)(966005)(41300700001)(316002)(36756003)(2616005)(40460700003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2023 18:15:58.3294 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 862b2080-7275-4fa2-b38f-08dbb54ea50a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003447.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5399 Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:16:24 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777038792458084473 X-GMAIL-MSGID: 1777038792458084473 |
Series |
PCI: of: Fix memory leak when of_changeset_create_node() failed
|
|
Commit Message
Lizhi Hou
Sept. 14, 2023, 6:15 p.m. UTC
Destroy and free cset when failure happens.
Fixes: 407d1a51921e ("PCI: Create device tree node for bridge")
Reported-by: Herve Codina <herve.codina@bootlin.com>
Closes: https://lore.kernel.org/all/20230911171319.495bb837@bootlin.com/
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
drivers/pci/of.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
Hi Lizhi On Thu, 14 Sep 2023 11:15:51 -0700 Lizhi Hou <lizhi.hou@amd.com> wrote: > Destroy and free cset when failure happens. > > Fixes: 407d1a51921e ("PCI: Create device tree node for bridge") > Reported-by: Herve Codina <herve.codina@bootlin.com> > Closes: https://lore.kernel.org/all/20230911171319.495bb837@bootlin.com/ > Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> > --- > drivers/pci/of.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/of.c b/drivers/pci/of.c > index 2af64bcb7da3..67bbfa2fca59 100644 Why this patch alone ? The issue fixed by this patch is related to the patch 2 in a series under review https://lore.kernel.org/linux-kernel/ZQGaSr+G5qu%2F8nJZ@smile.fi.intel.com/ Is the patch 2 in this series already applied by some maintainers ? You have to fix the patch in the series sending a new iteration of the series. This patch alone does not make sense. Otherwise, the modifications to fix the issue seem good. Regards, Hervé > --- a/drivers/pci/of.c > +++ b/drivers/pci/of.c > @@ -663,7 +663,6 @@ void of_pci_make_dev_node(struct pci_dev *pdev) > np = of_changeset_create_node(cset, ppnode, name); > if (!np) > goto failed; > - np->data = cset; > > ret = of_pci_add_properties(pdev, cset, np); > if (ret) > @@ -673,12 +672,17 @@ void of_pci_make_dev_node(struct pci_dev *pdev) > if (ret) > goto failed; > > + np->data = cset; > pdev->dev.of_node = np; > kfree(name); > > return; > > failed: > + if (cset) { > + of_changeset_destroy(cset); > + kfree(cset); > + } > if (np) > of_node_put(np); > kfree(name);
On 9/15/23 00:04, Herve Codina wrote: > Hi Lizhi > > On Thu, 14 Sep 2023 11:15:51 -0700 > Lizhi Hou <lizhi.hou@amd.com> wrote: > >> Destroy and free cset when failure happens. >> >> Fixes: 407d1a51921e ("PCI: Create device tree node for bridge") >> Reported-by: Herve Codina <herve.codina@bootlin.com> >> Closes: https://lore.kernel.org/all/20230911171319.495bb837@bootlin.com/ >> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> >> --- >> drivers/pci/of.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/pci/of.c b/drivers/pci/of.c >> index 2af64bcb7da3..67bbfa2fca59 100644 > Why this patch alone ? > The issue fixed by this patch is related to the patch 2 in a series under review > https://lore.kernel.org/linux-kernel/ZQGaSr+G5qu%2F8nJZ@smile.fi.intel.com/ > Is the patch 2 in this series already applied by some maintainers ? Yes. > > You have to fix the patch in the series sending a new iteration of the series. > > This patch alone does not make sense. > > Otherwise, the modifications to fix the issue seem good. > > Regards, > Hervé > >> --- a/drivers/pci/of.c >> +++ b/drivers/pci/of.c >> @@ -663,7 +663,6 @@ void of_pci_make_dev_node(struct pci_dev *pdev) >> np = of_changeset_create_node(cset, ppnode, name); >> if (!np) >> goto failed; >> - np->data = cset; >> >> ret = of_pci_add_properties(pdev, cset, np); >> if (ret) >> @@ -673,12 +672,17 @@ void of_pci_make_dev_node(struct pci_dev *pdev) >> if (ret) >> goto failed; >> >> + np->data = cset; >> pdev->dev.of_node = np; >> kfree(name); >> >> return; >> >> failed: >> + if (cset) { >> + of_changeset_destroy(cset); >> + kfree(cset); >> + } >> if (np) >> of_node_put(np); >> kfree(name);
On Thu, Sep 14, 2023 at 1:16 PM Lizhi Hou <lizhi.hou@amd.com> wrote: > > Destroy and free cset when failure happens. > > Fixes: 407d1a51921e ("PCI: Create device tree node for bridge") > Reported-by: Herve Codina <herve.codina@bootlin.com> > Closes: https://lore.kernel.org/all/20230911171319.495bb837@bootlin.com/ > Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> > --- > drivers/pci/of.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/of.c b/drivers/pci/of.c > index 2af64bcb7da3..67bbfa2fca59 100644 > --- a/drivers/pci/of.c > +++ b/drivers/pci/of.c > @@ -663,7 +663,6 @@ void of_pci_make_dev_node(struct pci_dev *pdev) > np = of_changeset_create_node(cset, ppnode, name); > if (!np) > goto failed; > - np->data = cset; > > ret = of_pci_add_properties(pdev, cset, np); > if (ret) > @@ -673,12 +672,17 @@ void of_pci_make_dev_node(struct pci_dev *pdev) > if (ret) > goto failed; > > + np->data = cset; > pdev->dev.of_node = np; > kfree(name); > > return; > > failed: > + if (cset) { Instead of adding more if's, use multiple goto labels which is the normal cleanup style. Note that there's a new cleanup.h thing that can do some automatic cleanups. Not sure if that works or helps here. > + of_changeset_destroy(cset); > + kfree(cset); > + } > if (np) > of_node_put(np); > kfree(name); > -- > 2.34.1 >
On 9/15/23 09:20, Rob Herring wrote: > On Thu, Sep 14, 2023 at 1:16 PM Lizhi Hou <lizhi.hou@amd.com> wrote: >> Destroy and free cset when failure happens. >> >> Fixes: 407d1a51921e ("PCI: Create device tree node for bridge") >> Reported-by: Herve Codina <herve.codina@bootlin.com> >> Closes: https://lore.kernel.org/all/20230911171319.495bb837@bootlin.com/ >> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> >> --- >> drivers/pci/of.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/pci/of.c b/drivers/pci/of.c >> index 2af64bcb7da3..67bbfa2fca59 100644 >> --- a/drivers/pci/of.c >> +++ b/drivers/pci/of.c >> @@ -663,7 +663,6 @@ void of_pci_make_dev_node(struct pci_dev *pdev) >> np = of_changeset_create_node(cset, ppnode, name); >> if (!np) >> goto failed; >> - np->data = cset; >> >> ret = of_pci_add_properties(pdev, cset, np); >> if (ret) >> @@ -673,12 +672,17 @@ void of_pci_make_dev_node(struct pci_dev *pdev) >> if (ret) >> goto failed; >> >> + np->data = cset; >> pdev->dev.of_node = np; >> kfree(name); >> >> return; >> >> failed: >> + if (cset) { > Instead of adding more if's, use multiple goto labels which is the > normal cleanup style. Note that there's a new cleanup.h thing that can > do some automatic cleanups. Not sure if that works or helps here. Ok. I will create another patch to use multiple goto labels. Lizhi > >> + of_changeset_destroy(cset); >> + kfree(cset); >> + } >> if (np) >> of_node_put(np); >> kfree(name); >> -- >> 2.34.1 >>
diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 2af64bcb7da3..67bbfa2fca59 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -663,7 +663,6 @@ void of_pci_make_dev_node(struct pci_dev *pdev) np = of_changeset_create_node(cset, ppnode, name); if (!np) goto failed; - np->data = cset; ret = of_pci_add_properties(pdev, cset, np); if (ret) @@ -673,12 +672,17 @@ void of_pci_make_dev_node(struct pci_dev *pdev) if (ret) goto failed; + np->data = cset; pdev->dev.of_node = np; kfree(name); return; failed: + if (cset) { + of_changeset_destroy(cset); + kfree(cset); + } if (np) of_node_put(np); kfree(name);