powerpc: MVME5100 fixes and cleanups
Subsystems (2)
cover powerpc: MVME5100 fixes and cleanups
Patch 1 removes a dtc warning, patch 2 prevents an out-of-bounds read, and patch 3 fixes the function name in a log message.
Patch 4 replaces hard-coded function names with __func__, patch 5 marks pci_membase as __initdata, and patch 6 removes redundant initializations.
Thorsten Blum (6):
powerpc: dts: mvme5100: Drop #interrupt-cells from ISA node powerpc/embedded6xx: Validate bus-range length in mvme5100_add_bridge() powerpc/embedded6xx: Fix logged function name in mvme5100_add_bridge() powerpc/embedded6xx: Use __func__ in mvme5100_pic_init() powerpc/embedded6xx: Mark pci_membase as __initdata powerpc/embedded6xx: Drop redundant initializations
arch/powerpc/boot/dts/mvme5100.dts | 1 - arch/powerpc/platforms/embedded6xx/mvme5100.c | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-)
PATCH 1/6 powerpc: dts: mvme5100: Drop #interrupt-cells from ISA node
The ISA node does not provide interrupts. Its interrupt-parent property points to the i8259 controller, which already defines #interrupt-cells.
Remove the #interrupt-cells property from the ISA node to fix the following dtc warning:
Warning (interrupt_provider): /pci@feff0000/isa:
'#interrupt-cells' found, but node is not an interrupt provider
--- arch/powerpc/boot/dts/mvme5100.dts | 1 - 1 file changed, 1 deletion(-)
arch/powerpc/boot/dts/mvme5100.dts +0 -1
@@ -155,7 +155,6 @@ pci0: pci@feff0000 { isa { #address-cells = <2>; #size-cells = <1>; - #interrupt-cells = <2>; device_type = "isa"; compatible = "isa"; ranges = <0x00000001 0 0x01000000 0 0x00000000 0x00001000>;
PATCH 2/6 powerpc/embedded6xx: Validate bus-range length in mvme5100_add_bridge()
In reply to Thorsten Blummvme5100_add_bridge() reads two cells from the bus-range property without checking its length, and a truncated property can cause an out-of-bounds read.
Check the length before reading the bus numbers.
--- arch/powerpc/platforms/embedded6xx/mvme5100.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/platforms/embedded6xx/mvme5100.c +4 -0
@@ -114,6 +114,10 @@ static int __init mvme5100_add_bridge(struct device_node *dev)pr_info ("Adding PCI host bridge %pOF\n" , dev); bus_range =of_get_property (dev,"bus-range" , &len); +if (bus_range && len <2 *sizeof (*bus_range)) { +pr_err ("bus-range property is too short\n" ); +return -EINVAL ; + } hose =pcibios_alloc_controller (dev);if (hose ==NULL )
PATCH 3/6 powerpc/embedded6xx: Fix logged function name in mvme5100_add_bridge()
In reply to Thorsten BlumUse __func__ to print the correct function name.
--- arch/powerpc/platforms/embedded6xx/mvme5100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/embedded6xx/mvme5100.c +1 -1
@@ -144,7 +144,7 @@ static int __init mvme5100_add_bridge(struct device_node *dev)return 0 ; } -pr_info ("mvme5100_pic_init: pci_membase: %x\n" , pci_membase); +pr_info ("%s: pci_membase: %x\n" , __func__, pci_membase);return 0 ; }
PATCH 4/6 powerpc/embedded6xx: Use __func__ in mvme5100_pic_init()
In reply to Thorsten BlumReplace the hard-coded function names with __func__.
--- arch/powerpc/platforms/embedded6xx/mvme5100.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/platforms/embedded6xx/mvme5100.c +3 -4
@@ -75,13 +75,13 @@ static void __init mvme5100_pic_init(void) cp =of_find_compatible_node (NULL ,NULL ,"chrp,iic" );if (cp ==NULL ) { -pr_warn ("mvme5100_pic_init: couldn't find i8259\n" ); +pr_warn ("%s: couldn't find i8259\n" , __func__);return ; } cirq =irq_of_parse_and_map (cp,0 );if (!cirq) { -pr_warn ("mvme5100_pic_init: no cascade interrupt?\n" ); +pr_warn ("%s: no cascade interrupt?\n" , __func__);return ; }
@@ -96,8 +96,7 @@ static void __init mvme5100_pic_init(void) }if (intack) -pr_debug ("mvme5100_pic_init: PCI 8259 intack at 0x%016lx\n" , - intack); +pr_debug ("%s: PCI 8259 intack at 0x%016lx\n" , __func__, intack);i8259_init (cp, intack);of_node_put (cp);
PATCH 5/6 powerpc/embedded6xx: Mark pci_membase as __initdata
In reply to Thorsten Blumpci_membase is only accessed by mvme5100_add_bridge() and mvme5100_pic_init(), both of which are __init functions.
--- arch/powerpc/platforms/embedded6xx/mvme5100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/embedded6xx/mvme5100.c +1 -1
@@ -35,7 +35,7 @@#define BOARD_EXT_FEATURE1_REG 0xfef880f0#define BOARD_EXT_FEATURE2_REG 0xfef88100 -static phys_addr_t pci_membase; +static phys_addr_t pci_membase__initdata ;static u_char *restart;static void mvme5100_8259_cascade (struct irq_desc *desc)
PATCH 6/6 powerpc/embedded6xx: Drop redundant initializations
In reply to Thorsten BlumThe variables are reassigned before their initial values are read. Drop the redundant initializations.
--- arch/powerpc/platforms/embedded6xx/mvme5100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/embedded6xx/mvme5100.c +2 -2
@@ -53,10 +53,10 @@ static void __init mvme5100_pic_init(void) {struct mpic *mpic;struct device_node *np; -struct device_node *cp =NULL ; +struct device_node *cp;unsigned int cirq;unsigned long intack =0 ; -const u32 *prop =NULL ; +const u32 *prop; np =of_find_node_by_type (NULL ,"open-pic" );if (!np) {