1 From 8204277ed0f4aeb7bb38d0d5f39d9ebcced92576 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Fri, 5 Jul 2013 00:24:38 +0200
4 Subject: [PATCH 15/17] bcma: fix handling of big addrl
6 The return value of bcma_erom_get_addr_desc() is a unsigned value and it
7 could wrap around in the two complement writing.
9 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
11 drivers/bcma/scan.c | 16 ++++++++--------
12 1 file changed, 8 insertions(+), 8 deletions(-)
14 --- a/drivers/bcma/scan.c
15 +++ b/drivers/bcma/scan.c
16 @@ -213,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct
20 -static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
21 +static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
24 u32 addrl, addrh, sizel, sizeh = 0;
25 @@ -225,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struc
26 ((ent & SCAN_ADDR_TYPE) != type) ||
27 (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) {
28 bcma_erom_push_ent(eromptr);
30 + return (u32)-EINVAL;
33 addrl = ent & SCAN_ADDR_ADDR;
34 @@ -273,7 +273,7 @@ static int bcma_get_next_core(struct bcm
35 struct bcma_device_id *match, int core_num,
36 struct bcma_device *core)
42 u8 ports[2], wrappers[2];
43 @@ -351,11 +351,11 @@ static int bcma_get_next_core(struct bcm
44 * the main register space for the core
46 tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
48 + if (tmp == 0 || IS_ERR_VALUE(tmp)) {
49 /* Try again to see if it is a bridge */
50 tmp = bcma_erom_get_addr_desc(bus, eromptr,
51 SCAN_ADDR_TYPE_BRIDGE, 0);
53 + if (tmp == 0 || IS_ERR_VALUE(tmp)) {
56 bcma_info(bus, "Bridge found\n");
57 @@ -369,7 +369,7 @@ static int bcma_get_next_core(struct bcm
59 tmp = bcma_erom_get_addr_desc(bus, eromptr,
60 SCAN_ADDR_TYPE_SLAVE, i);
62 + if (IS_ERR_VALUE(tmp)) {
63 /* no more entries for port _i_ */
64 /* pr_debug("erom: slave port %d "
65 * "has %d descriptors\n", i, j); */
66 @@ -386,7 +386,7 @@ static int bcma_get_next_core(struct bcm
68 tmp = bcma_erom_get_addr_desc(bus, eromptr,
69 SCAN_ADDR_TYPE_MWRAP, i);
71 + if (IS_ERR_VALUE(tmp)) {
72 /* no more entries for port _i_ */
73 /* pr_debug("erom: master wrapper %d "
74 * "has %d descriptors\n", i, j); */
75 @@ -404,7 +404,7 @@ static int bcma_get_next_core(struct bcm
77 tmp = bcma_erom_get_addr_desc(bus, eromptr,
78 SCAN_ADDR_TYPE_SWRAP, i + hack);
80 + if (IS_ERR_VALUE(tmp)) {
81 /* no more entries for port _i_ */
82 /* pr_debug("erom: master wrapper %d "
83 * has %d descriptors\n", i, j); */