[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a6e893a-da6b-7ae5-0b15-a6f0e978a045@amd.com>
Date: Fri, 15 Sep 2023 08:25:59 -0700
From: Lizhi Hou <lizhi.hou@....com>
To: Herve Codina <herve.codina@...tlin.com>
CC: <linux-pci@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <bhelgaas@...gle.com>,
<robh@...nel.org>
Subject: Re: [PATCH] PCI: of: Fix memory leak when of_changeset_create_node()
failed
On 9/15/23 00:04, Herve Codina wrote:
> Hi Lizhi
>
> On Thu, 14 Sep 2023 11:15:51 -0700
> Lizhi Hou <lizhi.hou@....com> wrote:
>
>> Destroy and free cset when failure happens.
>>
>> Fixes: 407d1a51921e ("PCI: Create device tree node for bridge")
>> Reported-by: Herve Codina <herve.codina@...tlin.com>
>> Closes: https://lore.kernel.org/all/20230911171319.495bb837@bootlin.com/
>> Signed-off-by: Lizhi Hou <lizhi.hou@....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);
Powered by blists - more mailing lists