* [PATCH] PCI: of_property: handle int_map allocation failure
@ 2024-03-03 10:57 Duoming Zhou
2024-05-02 22:18 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: Duoming Zhou @ 2024-03-03 10:57 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel, bhelgaas, Duoming Zhou
The kcalloc() in of_pci_prop_intr_map() will return null if
the physical memory has run out. As a result, both int_map
and mapp will point to the null area. If we dereference mapp,
the null pointer dereference bugs will happen.
Return -ENOMEM from of_pci_prop_intr_map() if kcalloc() fails
for int_map.
Fixes: 407d1a51921e ("PCI: Create device tree node for bridge")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
drivers/pci/of_property.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
index c2c7334152b..03539e50537 100644
--- a/drivers/pci/of_property.c
+++ b/drivers/pci/of_property.c
@@ -238,6 +238,8 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
return 0;
int_map = kcalloc(map_sz, sizeof(u32), GFP_KERNEL);
+ if (!int_map)
+ return -ENOMEM;
mapp = int_map;
list_for_each_entry(child, &pdev->subordinate->devices, bus_list) {
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: of_property: handle int_map allocation failure
2024-03-03 10:57 [PATCH] PCI: of_property: handle int_map allocation failure Duoming Zhou
@ 2024-05-02 22:18 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2024-05-02 22:18 UTC (permalink / raw)
To: Duoming Zhou; +Cc: linux-pci, linux-kernel, bhelgaas, Lizhi Hou, Rob Herring
[+cc Lizhi (when you post a fix to a commit, please always cc the
author of that original commit), Rob]
On Sun, Mar 03, 2024 at 06:57:29PM +0800, Duoming Zhou wrote:
> The kcalloc() in of_pci_prop_intr_map() will return null if
> the physical memory has run out. As a result, both int_map
> and mapp will point to the null area. If we dereference mapp,
> the null pointer dereference bugs will happen.
>
> Return -ENOMEM from of_pci_prop_intr_map() if kcalloc() fails
> for int_map.
>
> Fixes: 407d1a51921e ("PCI: Create device tree node for bridge")
> Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Applied to pci/of for v6.10, thanks!
Lizhi and Rob, let me know if you have any objections.
> ---
> drivers/pci/of_property.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
> index c2c7334152b..03539e50537 100644
> --- a/drivers/pci/of_property.c
> +++ b/drivers/pci/of_property.c
> @@ -238,6 +238,8 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
> return 0;
>
> int_map = kcalloc(map_sz, sizeof(u32), GFP_KERNEL);
> + if (!int_map)
> + return -ENOMEM;
> mapp = int_map;
>
> list_for_each_entry(child, &pdev->subordinate->devices, bus_list) {
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-02 22:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-03 10:57 [PATCH] PCI: of_property: handle int_map allocation failure Duoming Zhou
2024-05-02 22:18 ` Bjorn Helgaas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.