Commit 6651dba2 authored by Evgeny Novikov's avatar Evgeny Novikov Committed by Mauro Carvalho Chehab

media: isif: reset global state

isif_probe() invokes iounmap() on error handling paths, but it does not
reset the global state. So, later it can invoke iounmap() even when
ioremap() fails. This is the case also for isif_remove(). The patch
resets the global state after invoking iounmap() to avoid this.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarEvgeny Novikov <novikov@ispras.ru>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent d30ac9d8
...@@ -1075,10 +1075,14 @@ static int isif_probe(struct platform_device *pdev) ...@@ -1075,10 +1075,14 @@ static int isif_probe(struct platform_device *pdev)
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
i--; i--;
fail_nobase_res: fail_nobase_res:
if (isif_cfg.base_addr) if (isif_cfg.base_addr) {
iounmap(isif_cfg.base_addr); iounmap(isif_cfg.base_addr);
if (isif_cfg.linear_tbl0_addr) isif_cfg.base_addr = NULL;
}
if (isif_cfg.linear_tbl0_addr) {
iounmap(isif_cfg.linear_tbl0_addr); iounmap(isif_cfg.linear_tbl0_addr);
isif_cfg.linear_tbl0_addr = NULL;
}
while (i >= 0) { while (i >= 0) {
res = platform_get_resource(pdev, IORESOURCE_MEM, i); res = platform_get_resource(pdev, IORESOURCE_MEM, i);
...@@ -1096,8 +1100,11 @@ static int isif_remove(struct platform_device *pdev) ...@@ -1096,8 +1100,11 @@ static int isif_remove(struct platform_device *pdev)
int i = 0; int i = 0;
iounmap(isif_cfg.base_addr); iounmap(isif_cfg.base_addr);
isif_cfg.base_addr = NULL;
iounmap(isif_cfg.linear_tbl0_addr); iounmap(isif_cfg.linear_tbl0_addr);
isif_cfg.linear_tbl0_addr = NULL;
iounmap(isif_cfg.linear_tbl1_addr); iounmap(isif_cfg.linear_tbl1_addr);
isif_cfg.linear_tbl1_addr = NULL;
while (i < 3) { while (i < 3) {
res = platform_get_resource(pdev, IORESOURCE_MEM, i); res = platform_get_resource(pdev, IORESOURCE_MEM, i);
if (res) if (res)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment