Skip to content

Commit 7c6efda

Browse files
ozbenhpaulusmack
authored andcommitted
[POWERPC] Fix error handling in detecting legacy serial ports
Previously we weren't checking for failures in translating device addresses from the firmware. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 980a651 commit 7c6efda

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎arch/powerpc/kernel/legacy_serial.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ static int __init add_legacy_soc_port(struct device_node *np,
126126
return -1;
127127

128128
addr = of_translate_address(soc_dev, addrp);
129+
if (addr == OF_BAD_ADDR)
130+
return -1;
129131

130132
/* Add port, irq will be dealt with later. We passed a translated
131133
* IO port value. It will be fixed up later along with the irq
@@ -141,6 +143,8 @@ static int __init add_legacy_isa_port(struct device_node *np,
141143
int index = -1;
142144
phys_addr_t taddr;
143145

146+
DBG(" -> add_legacy_isa_port(%s)\n", np->full_name);
147+
144148
/* Get the ISA port number */
145149
reg = (u32 *)get_property(np, "reg", NULL);
146150
if (reg == NULL)
@@ -161,9 +165,12 @@ static int __init add_legacy_isa_port(struct device_node *np,
161165

162166
/* Translate ISA address */
163167
taddr = of_translate_address(np, reg);
168+
if (taddr == OF_BAD_ADDR)
169+
return -1;
164170

165171
/* Add port, irq will be dealt with later */
166-
return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr, NO_IRQ, UPF_BOOT_AUTOCONF);
172+
return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr,
173+
NO_IRQ, UPF_BOOT_AUTOCONF);
167174

168175
}
169176

@@ -176,6 +183,8 @@ static int __init add_legacy_pci_port(struct device_node *np,
176183
unsigned int flags;
177184
int iotype, index = -1, lindex = 0;
178185

186+
DBG(" -> add_legacy_pci_port(%s)\n", np->full_name);
187+
179188
/* We only support ports that have a clock frequency properly
180189
* encoded in the device-tree (that is have an fcode). Anything
181190
* else can't be used that early and will be normally probed by
@@ -194,6 +203,8 @@ static int __init add_legacy_pci_port(struct device_node *np,
194203
/* We only support BAR 0 for now */
195204
iotype = (flags & IORESOURCE_MEM) ? UPIO_MEM : UPIO_PORT;
196205
addr = of_translate_address(pci_dev, addrp);
206+
if (addr == OF_BAD_ADDR)
207+
return -1;
197208

198209
/* Set the IO base to the same as the translated address for MMIO,
199210
* or to the domain local IO base for PIO (it will be fixed up later)

0 commit comments

Comments
 (0)