aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2008-02-08 00:37:02 -0500
committerPaul Mackerras <paulus@samba.org>2008-02-08 03:52:39 -0500
commitccd05d086f82dba2ab117dcaf4a38cbb2863a439 (patch)
treeb40ca433d1dafab38f0ec35fae3e672c9e3d36ec /arch/powerpc
parent85687ff2b4eab47f4d637a0d3a482bb955d3cbd4 (diff)
[POWERPC] Fix cell IOMMU null pointer explosion on old firmwares
The cell IOMMU fixed mapping support has a null pointer bug if you run it on older firmwares that don't contain the "dma-ranges" properties. Fix it and convert to using of_get_next_parent() while we're there. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/cell/iommu.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index df330666ccc9..a276064471b3 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -26,6 +26,7 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/notifier.h> 28#include <linux/notifier.h>
29#include <linux/of.h>
29#include <linux/of_platform.h> 30#include <linux/of_platform.h>
30 31
31#include <asm/prom.h> 32#include <asm/prom.h>
@@ -789,18 +790,16 @@ static int __init cell_iommu_init_disabled(void)
789static u64 cell_iommu_get_fixed_address(struct device *dev) 790static u64 cell_iommu_get_fixed_address(struct device *dev)
790{ 791{
791 u64 cpu_addr, size, best_size, pci_addr = OF_BAD_ADDR; 792 u64 cpu_addr, size, best_size, pci_addr = OF_BAD_ADDR;
792 struct device_node *tmp, *np; 793 struct device_node *np;
793 const u32 *ranges = NULL; 794 const u32 *ranges = NULL;
794 int i, len, best; 795 int i, len, best;
795 796
796 np = dev->archdata.of_node; 797 np = of_node_get(dev->archdata.of_node);
797 of_node_get(np); 798 while (np) {
798 ranges = of_get_property(np, "dma-ranges", &len);
799 while (!ranges && np) {
800 tmp = of_get_parent(np);
801 of_node_put(np);
802 np = tmp;
803 ranges = of_get_property(np, "dma-ranges", &len); 799 ranges = of_get_property(np, "dma-ranges", &len);
800 if (ranges)
801 break;
802 np = of_get_next_parent(np);
804 } 803 }
805 804
806 if (!ranges) { 805 if (!ranges) {