* [PATCH 1/1] powerpc/iommu: Handling null return of kzalloc_node
@ 2014-06-10 7:32 Zhouyi Zhou
2015-01-30 2:17 ` [1/1] " Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Zhouyi Zhou @ 2014-06-10 7:32 UTC (permalink / raw)
To: benh, paulus, aik, anton, nacc, alistair, deepthi, linuxppc-dev,
linux-kernel
Cc: Zhouyi Zhou, Zhouyi Zhou
NULL return of kzalloc_node should be handled
Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
---
arch/powerpc/platforms/pseries/iommu.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 33b552f..593cd3d 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -613,7 +613,11 @@ static void pci_dma_bus_setup_pSeries(struct pci_bus *bus)
tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
pci->phb->node);
-
+ if (!tbl) {
+ pr_debug(" out of memory, can't create iommu_table !\n");
+ return;
+ }
+
iommu_table_setparms(pci->phb, dn, tbl);
pci->iommu_table = iommu_init_table(tbl, pci->phb->node);
iommu_register_group(tbl, pci_domain_nr(bus), 0);
@@ -659,6 +663,10 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
if (!ppci->iommu_table) {
tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
ppci->phb->node);
+ if (!tbl) {
+ pr_debug(" out of memory, can't create iommu_table !\n");
+ return;
+ }
iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window);
ppci->iommu_table = iommu_init_table(tbl, ppci->phb->node);
iommu_register_group(tbl, pci_domain_nr(bus), 0);
@@ -686,6 +694,11 @@ static void pci_dma_dev_setup_pSeries(struct pci_dev *dev)
pr_debug(" --> first child, no bridge. Allocating iommu table.\n");
tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
phb->node);
+ if (!tbl) {
+ pr_debug(" out of memory, can't create iommu_table !\n");
+ return;
+ }
+
iommu_table_setparms(phb, dn, tbl);
PCI_DN(dn)->iommu_table = iommu_init_table(tbl, phb->node);
iommu_register_group(tbl, pci_domain_nr(phb->bus), 0);
@@ -1102,6 +1116,10 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
if (!pci->iommu_table) {
tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
pci->phb->node);
+ if (!tbl) {
+ pr_debug(" out of memory, can't create iommu_table !\n");
+ return;
+ }
iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window);
pci->iommu_table = iommu_init_table(tbl, pci->phb->node);
iommu_register_group(tbl, pci_domain_nr(pci->phb->bus), 0);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [1/1] powerpc/iommu: Handling null return of kzalloc_node
2014-06-10 7:32 [PATCH 1/1] powerpc/iommu: Handling null return of kzalloc_node Zhouyi Zhou
@ 2015-01-30 2:17 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2015-01-30 2:17 UTC (permalink / raw)
To: Zhouyi Zhou, benh, paulus, aik, anton, nacc, alistair, deepthi,
linuxppc-dev, linux-kernel
Cc: Zhouyi Zhou, Zhouyi Zhou
On Tue, 2014-10-06 at 07:32:10 UTC, Zhouyi Zhou wrote:
> NULL return of kzalloc_node should be handled
Yeah it should.
But just returning doesn't seem like it's going to end well. We end up with a
device that's not properly setup.
I think we need to rework that further so that either the error is propagated
up the stack, or the device is left in a working but degraded state.
cheers
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index 33b552f..593cd3d 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -613,7 +613,11 @@ static void pci_dma_bus_setup_pSeries(struct pci_bus *bus)
>
> tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
> pci->phb->node);
> -
> + if (!tbl) {
> + pr_debug(" out of memory, can't create iommu_table !\n");
> + return;
> + }
> +
> iommu_table_setparms(pci->phb, dn, tbl);
> pci->iommu_table = iommu_init_table(tbl, pci->phb->node);
> iommu_register_group(tbl, pci_domain_nr(bus), 0);
> @@ -659,6 +663,10 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
> if (!ppci->iommu_table) {
> tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
> ppci->phb->node);
> + if (!tbl) {
> + pr_debug(" out of memory, can't create iommu_table !\n");
> + return;
> + }
> iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window);
> ppci->iommu_table = iommu_init_table(tbl, ppci->phb->node);
> iommu_register_group(tbl, pci_domain_nr(bus), 0);
> @@ -686,6 +694,11 @@ static void pci_dma_dev_setup_pSeries(struct pci_dev *dev)
> pr_debug(" --> first child, no bridge. Allocating iommu table.\n");
> tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
> phb->node);
> + if (!tbl) {
> + pr_debug(" out of memory, can't create iommu_table !\n");
> + return;
> + }
> +
> iommu_table_setparms(phb, dn, tbl);
> PCI_DN(dn)->iommu_table = iommu_init_table(tbl, phb->node);
> iommu_register_group(tbl, pci_domain_nr(phb->bus), 0);
> @@ -1102,6 +1116,10 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
> if (!pci->iommu_table) {
> tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
> pci->phb->node);
> + if (!tbl) {
> + pr_debug(" out of memory, can't create iommu_table !\n");
> + return;
> + }
> iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window);
> pci->iommu_table = iommu_init_table(tbl, pci->phb->node);
> iommu_register_group(tbl, pci_domain_nr(pci->phb->bus), 0);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-30 2:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-10 7:32 [PATCH 1/1] powerpc/iommu: Handling null return of kzalloc_node Zhouyi Zhou
2015-01-30 2:17 ` [1/1] " Michael Ellerman
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.