提交 710d86f8 编写于 作者: I Ilia Mirkin 提交者: Ralf Baechle

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: NIlia Mirkin <imirkin@alum.mit.edu>
Acked-by: NHauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: NJohn Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/6211/
上级 0ded1bec
...@@ -135,7 +135,7 @@ static void nvram_read_leddc(const char *prefix, const char *name, ...@@ -135,7 +135,7 @@ static void nvram_read_leddc(const char *prefix, const char *name,
} }
static void nvram_read_macaddr(const char *prefix, const char *name, static void nvram_read_macaddr(const char *prefix, const char *name,
u8 (*val)[6], bool fallback) u8 val[6], bool fallback)
{ {
char buf[100]; char buf[100];
int err; int err;
...@@ -144,11 +144,11 @@ static void nvram_read_macaddr(const char *prefix, const char *name, ...@@ -144,11 +144,11 @@ static void nvram_read_macaddr(const char *prefix, const char *name,
if (err < 0) if (err < 0)
return; return;
bcm47xx_nvram_parse_macaddr(buf, *val); bcm47xx_nvram_parse_macaddr(buf, val);
} }
static void nvram_read_alpha2(const char *prefix, const char *name, static void nvram_read_alpha2(const char *prefix, const char *name,
char (*val)[2], bool fallback) char val[2], bool fallback)
{ {
char buf[10]; char buf[10];
int err; int err;
...@@ -162,7 +162,7 @@ static void nvram_read_alpha2(const char *prefix, const char *name, ...@@ -162,7 +162,7 @@ static void nvram_read_alpha2(const char *prefix, const char *name,
pr_warn("alpha2 is too long %s\n", buf); pr_warn("alpha2 is too long %s\n", buf);
return; return;
} }
memcpy(val, buf, sizeof(val)); memcpy(val, buf, 2);
} }
static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom, 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,7 +180,7 @@ static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom,
fallback); fallback);
nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0, nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0,
fallback); fallback);
nvram_read_alpha2(prefix, "ccode", &sprom->alpha2, fallback); nvram_read_alpha2(prefix, "ccode", sprom->alpha2, fallback);
} }
static void bcm47xx_fill_sprom_r12389(struct ssb_sprom *sprom, 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,20 +633,20 @@ static void bcm47xx_fill_sprom_path_r45(struct ssb_sprom *sprom,
static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom,
const char *prefix, bool fallback) const char *prefix, bool fallback)
{ {
nvram_read_macaddr(prefix, "et0macaddr", &sprom->et0mac, fallback); nvram_read_macaddr(prefix, "et0macaddr", sprom->et0mac, fallback);
nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0, nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0,
fallback); fallback);
nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0, nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0,
fallback); fallback);
nvram_read_macaddr(prefix, "et1macaddr", &sprom->et1mac, fallback); nvram_read_macaddr(prefix, "et1macaddr", sprom->et1mac, fallback);
nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0, nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0,
fallback); fallback);
nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0, nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0,
fallback); fallback);
nvram_read_macaddr(prefix, "macaddr", &sprom->il0mac, fallback); nvram_read_macaddr(prefix, "macaddr", sprom->il0mac, fallback);
nvram_read_macaddr(prefix, "il0macaddr", &sprom->il0mac, fallback); nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback);
} }
static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix, static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册