brcm47xx: fix memory leak, backport from the mainline kernel
[openwrt.git] / target / linux / brcm47xx / patches-3.2 / 235-bcma-fix-memleak.patch
1 --- a/drivers/bcma/scan.c
2 +++ b/drivers/bcma/scan.c
3 @@ -458,15 +458,18 @@ int bcma_bus_scan(struct bcma_bus *bus)
4                 core->bus = bus;
5  
6                 err = bcma_get_next_core(bus, &eromptr, NULL, core_num, core);
7 -               if (err == -ENODEV) {
8 -                       core_num++;
9 -                       continue;
10 -               } else if (err == -ENXIO)
11 -                       continue;
12 -               else if (err == -ESPIPE)
13 -                       break;
14 -               else if (err < 0)
15 +               if (err < 0) {
16 +                       kfree(core);
17 +                       if (err == -ENODEV) {
18 +                               core_num++;
19 +                               continue;
20 +                       } else if (err == -ENXIO) {
21 +                               continue;
22 +                       } else if (err == -ESPIPE) {
23 +                               break;
24 +                       }
25                         return err;
26 +               }
27  
28                 core->core_index = core_num++;
29                 bus->nr_cores++;