diff options
author | Ilia Mirkin <imirkin@alum.mit.edu> | 2013-12-06 18:56:53 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-01-22 14:18:56 -0500 |
commit | 710d86f8bc4515a906799b85135e6f6962703e01 (patch) | |
tree | be41d76d378a740adf2e294d804b31192196401b | |
parent | 0ded1becc8deaea66f8837c274fd84facc257919 (diff) |
MIPS: BCM47XX: Fix some very confused types and data corruption
Fix nvram_read_alpha2 copying too many bytes over the ssb_sprom
structure. Also fix the arguments of the read_macaddr, although the code
was technically not wrong before due to an extra dereference.
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: John Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/6211/
-rw-r--r-- | arch/mips/bcm47xx/sprom.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c index ad03c931b905..a8b5408dd349 100644 --- a/arch/mips/bcm47xx/sprom.c +++ b/arch/mips/bcm47xx/sprom.c | |||
@@ -135,7 +135,7 @@ static void nvram_read_leddc(const char *prefix, const char *name, | |||
135 | } | 135 | } |
136 | 136 | ||
137 | static void nvram_read_macaddr(const char *prefix, const char *name, | 137 | static void nvram_read_macaddr(const char *prefix, const char *name, |
138 | u8 (*val)[6], bool fallback) | 138 | u8 val[6], bool fallback) |
139 | { | 139 | { |
140 | char buf[100]; | 140 | char buf[100]; |
141 | int err; | 141 | int err; |
@@ -144,11 +144,11 @@ static void nvram_read_macaddr(const char *prefix, const char *name, | |||
144 | if (err < 0) | 144 | if (err < 0) |
145 | return; | 145 | return; |
146 | 146 | ||
147 | bcm47xx_nvram_parse_macaddr(buf, *val); | 147 | bcm47xx_nvram_parse_macaddr(buf, val); |
148 | } | 148 | } |
149 | 149 | ||
150 | static void nvram_read_alpha2(const char *prefix, const char *name, | 150 | static void nvram_read_alpha2(const char *prefix, const char *name, |
151 | char (*val)[2], bool fallback) | 151 | char val[2], bool fallback) |
152 | { | 152 | { |
153 | char buf[10]; | 153 | char buf[10]; |
154 | int err; | 154 | int err; |
@@ -162,7 +162,7 @@ static void nvram_read_alpha2(const char *prefix, const char *name, | |||
162 | pr_warn("alpha2 is too long %s\n", buf); | 162 | pr_warn("alpha2 is too long %s\n", buf); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | memcpy(val, buf, sizeof(val)); | 165 | memcpy(val, buf, 2); |
166 | } | 166 | } |
167 | 167 | ||
168 | static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom, | 168 | static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom, |
@@ -180,7 +180,7 @@ static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom, | |||
180 | fallback); | 180 | fallback); |
181 | nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0, | 181 | nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0, |
182 | fallback); | 182 | fallback); |
183 | nvram_read_alpha2(prefix, "ccode", &sprom->alpha2, fallback); | 183 | nvram_read_alpha2(prefix, "ccode", sprom->alpha2, fallback); |
184 | } | 184 | } |
185 | 185 | ||
186 | static void bcm47xx_fill_sprom_r12389(struct ssb_sprom *sprom, | 186 | static void bcm47xx_fill_sprom_r12389(struct ssb_sprom *sprom, |
@@ -633,20 +633,20 @@ static void bcm47xx_fill_sprom_path_r45(struct ssb_sprom *sprom, | |||
633 | static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, | 633 | static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, |
634 | const char *prefix, bool fallback) | 634 | const char *prefix, bool fallback) |
635 | { | 635 | { |
636 | nvram_read_macaddr(prefix, "et0macaddr", &sprom->et0mac, fallback); | 636 | nvram_read_macaddr(prefix, "et0macaddr", sprom->et0mac, fallback); |
637 | nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0, | 637 | nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0, |
638 | fallback); | 638 | fallback); |
639 | nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0, | 639 | nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0, |
640 | fallback); | 640 | fallback); |
641 | 641 | ||
642 | nvram_read_macaddr(prefix, "et1macaddr", &sprom->et1mac, fallback); | 642 | nvram_read_macaddr(prefix, "et1macaddr", sprom->et1mac, fallback); |
643 | nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0, | 643 | nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0, |
644 | fallback); | 644 | fallback); |
645 | nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0, | 645 | nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0, |
646 | fallback); | 646 | fallback); |
647 | 647 | ||
648 | nvram_read_macaddr(prefix, "macaddr", &sprom->il0mac, fallback); | 648 | nvram_read_macaddr(prefix, "macaddr", sprom->il0mac, fallback); |
649 | nvram_read_macaddr(prefix, "il0macaddr", &sprom->il0mac, fallback); | 649 | nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback); |
650 | } | 650 | } |
651 | 651 | ||
652 | static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix, | 652 | static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix, |