提交 a566059d 编写于 作者: F Florian Fainelli 提交者: David S. Miller

net: dsa: bcm_sf2: fix unmapping registers in case of errors

In case we fail to ioremap() one of our registers, we would be leaking
existing mappings, unwind those accordingly on errors.

Fixes: 246d7f77 ("net: dsa: add Broadcom SF2 switch driver")
Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a620a6bc
......@@ -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++;
}
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册