Skip to content

Commit

Permalink
[SPARC]: Fix EBUS use of uninitialized variable.
Browse files Browse the repository at this point in the history
If of_get_property() fails, it returns NULL and the 'len'
parameter is undefined.  So we need to explicitly set len
to zero in such cases.

Noticed by Al Viro.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 27, 2007
1 parent ff0ce68 commit 9c908f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions arch/sparc/kernel/ebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *d
dev->prom_node = dp;

regs = of_get_property(dp, "reg", &len);
if (!regs)
len = 0;
if (len % sizeof(struct linux_prom_registers)) {
prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
dev->prom_node->name, len,
Expand Down
5 changes: 4 additions & 1 deletion arch/sparc64/kernel/ebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de
dev->num_addrs = 0;
dev->num_irqs = 0;
} else {
(void) of_get_property(dp, "reg", &len);
const int *regs = of_get_property(dp, "reg", &len);

if (!regs)
len = 0;
dev->num_addrs = len / sizeof(struct linux_prom_registers);

for (i = 0; i < dev->num_addrs; i++)
Expand Down

0 comments on commit 9c908f9

Please sign in to comment.