Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: bcm: brcmstb: biuctrl: fix of_iomap leak

Smatch reports:

drivers/soc/bcm/brcmstb/biuctrl.c:291 setup_hifcpubiuctrl_regs() warn:
'cpubiuctrl_base' from of_iomap() not released on lines: 291.

This is because in setup_hifcpubiuctrl_regs(),
cpubiuctrl_base is not released when handle error, which may cause a leak.
To fix this, iounmap is added when handle error.

Fixes: 22f7a9116eba ("soc: brcmstb: Correct CPU_CREDIT_REG offset for Brahma-B53 CPUs")
Signed-off-by: Zhaoyang Li <lizhaoyang04@hust.edu.cn>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Link: https://lore.kernel.org/r/20230327115422.1536615-1-lizhaoyang04@hust.edu.cn
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

authored by

Zhaoyang Li and committed by
Florian Fainelli
c3fbced9 69160dd0

+4
+4
drivers/soc/bcm/brcmstb/biuctrl.c
··· 288 288 if (BRCM_ID(family_id) == 0x7260 && BRCM_REV(family_id) == 0) 289 289 cpubiuctrl_regs = b53_cpubiuctrl_no_wb_regs; 290 290 out: 291 + if (ret && cpubiuctrl_base) { 292 + iounmap(cpubiuctrl_base); 293 + cpubiuctrl_base = NULL; 294 + } 291 295 return ret; 292 296 } 293 297