From: Dan Carpenter <dan.carpenter@linaro.org>
To: Zhe Qiao <qiaozhe@iscas.ac.cn>
Cc: rafael@kernel.org, bhelgaas@google.com, lenb@kernel.org,
kwilczynski@kernel.org, sashal@kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-acpi@vger.kernel.org
Subject: Re: [PATCH v2] PCI/ACPI: Fix double free bug in pci_acpi_scan_root() function
Date: Wed, 18 Jun 2025 19:02:27 +0300 [thread overview]
Message-ID: <f04d01a7-28f5-41ea-85f6-ba0e67c80428@suswa.mountain> (raw)
In-Reply-To: <20250617023738.779081-1-qiaozhe@iscas.ac.cn>
Wait, what? We can't just delete pci_acpi_generic_release_info().
What's going to free all those things on the success path? I
don't understand.
I had suggested you do something like this:
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 74ade4160314..ff5799b696d6 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -1012,20 +1012,20 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
root->segment, busnum);
if (ops->init_info && ops->init_info(info))
- goto out_release_info;
+ return NULL;
if (ops->prepare_resources)
ret = ops->prepare_resources(info);
else
ret = acpi_pci_probe_root_resources(info);
if (ret < 0)
- goto out_release_info;
+ goto cleanup_init_info;
pci_acpi_root_add_resources(info);
pci_add_resource(&info->resources, &root->secondary);
bus = pci_create_root_bus(NULL, busnum, ops->pci_ops,
sysdata, &info->resources);
if (!bus)
- goto out_release_info;
+ goto cleanup_acpi_pci_probe_root_resources;
host_bridge = to_pci_host_bridge(bus->bridge);
if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
@@ -1053,8 +1053,10 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node);
return bus;
+cleanup_acpi_pci_probe_root_resources:
+ free_something_with_probe();
out_release_info:
- __acpi_pci_root_release_info(info);
+ free_something_info();
return NULL;
}
But you'd need to replace the dummy code with actual code and
change the callers etc. And I haven't looked at the actual
code to verify it's a good idea.
regards,
dan carpenter
prev parent reply other threads:[~2025-06-18 16:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 2:37 Zhe Qiao
2025-06-17 14:40 ` Bjorn Helgaas
2025-06-18 2:24 ` Zhe Qiao
2025-06-18 16:02 ` Dan Carpenter [this message]
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=f04d01a7-28f5-41ea-85f6-ba0e67c80428@suswa.mountain \
--to=dan.carpenter@linaro.org \
--cc=bhelgaas@google.com \
--cc=kwilczynski@kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=qiaozhe@iscas.ac.cn \
--cc=rafael@kernel.org \
--cc=sashal@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
all inboxes | Powered by JetHome®