Skip to content

Commit

Permalink
net: dsa: bcm_sf2: fix unmapping registers in case of errors
Browse files Browse the repository at this point in the history
In case we fail to ioremap() one of our registers, we would be leaking
existing mappings, unwind those accordingly on errors.

Fixes: 246d7f7 ("net: dsa: add Broadcom SF2 switch driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Nov 26, 2014
1 parent a620a6b commit a566059
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/dsa/bcm_sf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
*base = of_iomap(dn, i);
if (*base == NULL) {
pr_err("unable to find register: %s\n", reg_names[i]);
return -ENODEV;
ret = -ENOMEM;
goto out_unmap;
}
base++;
}
Expand Down Expand Up @@ -484,7 +485,8 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
out_unmap:
base = &priv->core;
for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
iounmap(*base);
if (*base)
iounmap(*base);
base++;
}
return ret;
Expand Down

0 comments on commit a566059

Please sign in to comment.