media: vpss: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Sat, 23 Mar 2019 02:51:06 +0000 (22:51 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 Aug 2019 07:33:15 +0000 (09:33 +0200)
[ Upstream commit e08f0761234def47961d3252eac09ccedfe4c6a0 ]

In case ioremap fails, the fix returns -ENOMEM to avoid NULL
pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/davinci/vpss.c

index fce86f1..c2c6898 100644 (file)
@@ -523,6 +523,11 @@ static int __init vpss_init(void)
                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;
+       }
+
        writel(VPSS_CLK_CTRL_VENCCLKEN |
                     VPSS_CLK_CTRL_DACCLKEN, oper_cfg.vpss_regs_base2);