From: Herve Codina <herve.codina@bootlin.com>
To: Lizhi Hou <lizhi.hou@amd.com>
Cc: <linux-pci@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <bhelgaas@google.com>,
<robh@kernel.org>
Subject: Re: [PATCH] PCI: of: Fix memory leak when of_changeset_create_node() failed
Date: Fri, 15 Sep 2023 09:04:50 +0200 [thread overview]
Message-ID: <20230915090450.206657cf@bootlin.com> (raw)
In-Reply-To: <1694715351-58279-1-git-send-email-lizhi.hou@amd.com>
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);
next prev parent reply other threads:[~2023-09-15 7:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 18:15 [PATCH] PCI: of: Fix memory leak when of_changeset_create_node() failed Lizhi Hou
2023-09-15 7:04 ` Herve Codina [this message]
2023-09-15 15:25 ` Lizhi Hou
2023-09-15 16:20 ` Rob Herring
2023-09-15 17:11 ` Lizhi Hou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230915090450.206657cf@bootlin.com \
--to=herve.codina@bootlin.com \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).