| 1 | --- a/drivers/bcma/scan.c |
| 2 | +++ b/drivers/bcma/scan.c |
| 3 | @@ -462,8 +462,10 @@ int bcma_bus_scan(struct bcma_bus *bus) |
| 4 | while (eromptr < eromend) { |
| 5 | struct bcma_device *other_core; |
| 6 | struct bcma_device *core = kzalloc(sizeof(*core), GFP_KERNEL); |
| 7 | - if (!core) |
| 8 | - return -ENOMEM; |
| 9 | + if (!core) { |
| 10 | + err = -ENOMEM; |
| 11 | + goto out; |
| 12 | + } |
| 13 | INIT_LIST_HEAD(&core->list); |
| 14 | core->bus = bus; |
| 15 | |
| 16 | @@ -478,7 +480,7 @@ int bcma_bus_scan(struct bcma_bus *bus) |
| 17 | } else if (err == -ESPIPE) { |
| 18 | break; |
| 19 | } |
| 20 | - return err; |
| 21 | + goto out; |
| 22 | } |
| 23 | |
| 24 | core->core_index = core_num++; |
| 25 | @@ -494,10 +496,12 @@ int bcma_bus_scan(struct bcma_bus *bus) |
| 26 | list_add_tail(&core->list, &bus->cores); |
| 27 | } |
| 28 | |
| 29 | + err = 0; |
| 30 | +out: |
| 31 | if (bus->hosttype == BCMA_HOSTTYPE_SOC) |
| 32 | iounmap(eromptr); |
| 33 | |
| 34 | - return 0; |
| 35 | + return err; |
| 36 | } |
| 37 | |
| 38 | int __init bcma_bus_scan_early(struct bcma_bus *bus, |
| 39 | @@ -537,7 +541,7 @@ int __init bcma_bus_scan_early(struct bc |
| 40 | else if (err == -ESPIPE) |
| 41 | break; |
| 42 | else if (err < 0) |
| 43 | - return err; |
| 44 | + goto out; |
| 45 | |
| 46 | core->core_index = core_num++; |
| 47 | bus->nr_cores++; |
| 48 | @@ -551,6 +555,7 @@ int __init bcma_bus_scan_early(struct bc |
| 49 | break; |
| 50 | } |
| 51 | |
| 52 | +out: |
| 53 | if (bus->hosttype == BCMA_HOSTTYPE_SOC) |
| 54 | iounmap(eromptr); |
| 55 | |
| 56 | |