Skip to content

Commit

Permalink
media: vpss: clean up resources in init
Browse files Browse the repository at this point in the history
If platform_driver_register() fails within vpss_init() resources are not
cleaned up. The patch fixes this issue by introducing the corresponding
error handling.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
eunovm authored and mchehab committed Jul 19, 2020
1 parent d70cca7 commit 9c487b0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions drivers/media/platform/davinci/vpss.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,19 +505,31 @@ static void vpss_exit(void)

static int __init vpss_init(void)
{
int ret;

if (!request_mem_region(VPSS_CLK_CTRL, 4, "vpss_clock_control"))
return -EBUSY;

oper_cfg.vpss_regs_base2 = ioremap(VPSS_CLK_CTRL, 4);
if (unlikely(!oper_cfg.vpss_regs_base2)) {
release_mem_region(VPSS_CLK_CTRL, 4);
return -ENOMEM;
ret = -ENOMEM;
goto err_ioremap;
}

writel(VPSS_CLK_CTRL_VENCCLKEN |
VPSS_CLK_CTRL_DACCLKEN, oper_cfg.vpss_regs_base2);
VPSS_CLK_CTRL_DACCLKEN, oper_cfg.vpss_regs_base2);

ret = platform_driver_register(&vpss_driver);
if (ret)
goto err_pd_register;

return 0;

return platform_driver_register(&vpss_driver);
err_pd_register:
iounmap(oper_cfg.vpss_regs_base2);
err_ioremap:
release_mem_region(VPSS_CLK_CTRL, 4);
return ret;
}
subsys_initcall(vpss_init);
module_exit(vpss_exit);

0 comments on commit 9c487b0

Please sign in to comment.