9c669e6cb5c81ea9f3b5b5706f4d4a2138d94177
[openwrt/openwrt.git] / target / linux / brcm47xx / patches-3.10 / 095-MIPS-BCM47XX-Fix-some-very-confused-types-and-data-c.patch
1 From 855094d7e46eb14c597ca09631cf95a92909982d Mon Sep 17 00:00:00 2001
2 From: Ilia Mirkin <imirkin@alum.mit.edu>
3 Date: Fri, 6 Dec 2013 18:56:53 -0500
4 Subject: [PATCH] MIPS: BCM47XX: Fix some very confused types and data
5 corruption
6
7 Fix nvram_read_alpha2 copying too many bytes over the ssb_sprom
8 structure. Also fix the arguments of the read_macaddr, although the code
9 was technically not wrong before due to an extra dereference.
10
11 Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
12 Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
13 Acked-by: John Crispin <blogic@openwrt.org>
14 Patchwork: http://patchwork.linux-mips.org/patch/6211/
15 ---
16 arch/mips/bcm47xx/sprom.c | 18 +++++++++---------
17 1 file changed, 9 insertions(+), 9 deletions(-)
18
19 --- a/arch/mips/bcm47xx/sprom.c
20 +++ b/arch/mips/bcm47xx/sprom.c
21 @@ -135,7 +135,7 @@ static void nvram_read_leddc(const char
22 }
23
24 static void nvram_read_macaddr(const char *prefix, const char *name,
25 - u8 (*val)[6], bool fallback)
26 + u8 val[6], bool fallback)
27 {
28 char buf[100];
29 int err;
30 @@ -144,11 +144,11 @@ static void nvram_read_macaddr(const cha
31 if (err < 0)
32 return;
33
34 - bcm47xx_nvram_parse_macaddr(buf, *val);
35 + bcm47xx_nvram_parse_macaddr(buf, val);
36 }
37
38 static void nvram_read_alpha2(const char *prefix, const char *name,
39 - char (*val)[2], bool fallback)
40 + char val[2], bool fallback)
41 {
42 char buf[10];
43 int err;
44 @@ -162,7 +162,7 @@ static void nvram_read_alpha2(const char
45 pr_warn("alpha2 is too long %s\n", buf);
46 return;
47 }
48 - memcpy(val, buf, sizeof(val));
49 + memcpy(val, buf, 2);
50 }
51
52 static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom,
53 @@ -181,7 +181,7 @@ static void bcm47xx_fill_sprom_r1234589(
54 fallback);
55 nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0,
56 fallback);
57 - nvram_read_alpha2(prefix, "ccode", &sprom->alpha2, fallback);
58 + nvram_read_alpha2(prefix, "ccode", sprom->alpha2, fallback);
59 }
60
61 static void bcm47xx_fill_sprom_r12389(struct ssb_sprom *sprom,
62 @@ -634,20 +634,20 @@ static void bcm47xx_fill_sprom_path_r45(
63 static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom,
64 const char *prefix, bool fallback)
65 {
66 - nvram_read_macaddr(prefix, "et0macaddr", &sprom->et0mac, fallback);
67 + nvram_read_macaddr(prefix, "et0macaddr", sprom->et0mac, fallback);
68 nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0,
69 fallback);
70 nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0,
71 fallback);
72
73 - nvram_read_macaddr(prefix, "et1macaddr", &sprom->et1mac, fallback);
74 + nvram_read_macaddr(prefix, "et1macaddr", sprom->et1mac, fallback);
75 nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0,
76 fallback);
77 nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0,
78 fallback);
79
80 - nvram_read_macaddr(prefix, "macaddr", &sprom->il0mac, fallback);
81 - nvram_read_macaddr(prefix, "il0macaddr", &sprom->il0mac, fallback);
82 + nvram_read_macaddr(prefix, "macaddr", sprom->il0mac, fallback);
83 + nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback);
84 }
85
86 static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix,