soc/tegra: fuse: add missing iounmap() on error in tegra_init_fuse()
PATCH 1/1 soc/tegra: fuse: add missing iounmap() on error in tegra_init_fuse()
Add the missing iounmap() before return from tegra_init_fuse() in the error handling case.
--- drivers/soc/tegra/fuse/fuse-tegra.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soc/tegra/fuse/fuse-tegra.c +3 -1
@@ -489,8 +489,10 @@ static int __init tegra_init_fuse(void)size_t size =sizeof (*fuse->lookups) * fuse->soc->num_lookups; fuse->lookups =kmemdup (fuse->soc->lookups, size,GFP_KERNEL ); -if (!fuse->lookups) +if (!fuse->lookups) { +iounmap (fuse->base);return -ENOMEM ; + }nvmem_add_cell_lookups (fuse->lookups, fuse->soc->num_lookups); }
Signature · 1 line
2.25.1
Quoted 16 lines · Yang Yingliang
Add the missing
iounmap()before return fromtegra_init_fuse()in the error handling case.Fixes 9f94fadd75d3 ("soc/tegra: fuse: Register cell lookups for compatibility")Reported-by Hulk Robot <[email protected]>Signed-off-by Yang Yingliang <[email protected]>--- drivers/soc/tegra/fuse/fuse-tegra.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/soc/tegra/fuse/fuse-tegra.c +0
-0@@ -489,8 +489,10 @@ static int __init tegra_init_fuse(void)size_t size =sizeof (*fuse->lookups) * fuse->soc->num_lookups;
drivers/soc/tegra/fuse/fuse-tegra.c static int __init tegra_init_fuse(void) · line 498
Quoted 10 lines
drivers/soc/tegra/fuse/fuse-tegra.c +3
-1fuse->lookups =kmemdup (fuse->soc->lookups, size,GFP_KERNEL ); -if (!fuse->lookups) +if (!fuse->lookups) { +iounmap (fuse->base);return -ENOMEM ; + }nvmem_add_cell_lookups (fuse->lookups, fuse->soc->num_lookups); }
I don't think that's a good idea. Given that this is an early_initcall, the failure doesn't actually prevent the driver from loading. There are other functions that rely on fuse->base staying around to access some of the registers in that I/O memory region.
I suppose we could remove the -ENOMEM return there and instead just skip registering the nvmem cell lookups, perhaps that would make this less confusing.
Thierry