LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] powerpc/pseries/iommu: Add check for iommu_pseries_alloc_group()
@ 2026-06-23 14:29 Haoxiang Li
  2026-06-24 15:14 ` Gaurav Batra
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-06-23 14:29 UTC (permalink / raw)
  To: gbatra, maddy, mpe, npiggin, chleroy, kees
  Cc: linuxppc-dev, linux-kernel, Haoxiang Li

Add check for the return value of iommu_pseries_alloc_group()
to prevent potential null pointer dereferences.

Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
- Changes in v2:
  - Add check for other callsites. Thanks, Gaurav!
---
 arch/powerpc/platforms/pseries/iommu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 3e1f915fe4f6..d97bde96dd4d 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -684,6 +684,9 @@ static void pci_dma_bus_setup_pSeries(struct pci_bus *bus)
 	pci->phb->dma_window_base_cur = 0x8000000ul;
 
 	pci->table_group = iommu_pseries_alloc_group(pci->phb->node);
+	if (!pci->table_group)
+		return;
+
 	tbl = pci->table_group->tables[0];
 
 	iommu_table_setparms(pci->phb, dn, tbl);
@@ -872,6 +875,9 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
 
 	if (!ppci->table_group) {
 		ppci->table_group = iommu_pseries_alloc_group(ppci->phb->node);
+		if (!ppci->table_group)
+			return;
+
 		tbl = ppci->table_group->tables[0];
 
 		iommu_table_setparms_common(tbl, ppci->phb->bus->number,
@@ -909,6 +915,9 @@ static void pci_dma_dev_setup_pSeries(struct pci_dev *dev)
 
 		pr_debug(" --> first child, no bridge. Allocating iommu table.\n");
 		PCI_DN(dn)->table_group = iommu_pseries_alloc_group(phb->node);
+		if (!PCI_DN(dn)->table_group)
+			return;
+
 		tbl = PCI_DN(dn)->table_group->tables[0];
 		iommu_table_setparms(phb, dn, tbl);
 
@@ -1875,6 +1884,9 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 	pci = PCI_DN(pdn);
 	if (!pci->table_group) {
 		pci->table_group = iommu_pseries_alloc_group(pci->phb->node);
+		if (!pci->table_group)
+			return;
+
 		tbl = pci->table_group->tables[0];
 
 		iommu_table_setparms_common(tbl, pci->phb->bus->number,
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-24 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 14:29 [PATCH v2] powerpc/pseries/iommu: Add check for iommu_pseries_alloc_group() Haoxiang Li
2026-06-24 15:14 ` Gaurav Batra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox