media: vpss: fix a potential NULL pointer dereference [Linux 4.4.187]

This Linux kernel change "media: vpss: fix a potential NULL pointer dereference" is included in the Linux 4.4.187 release. This change is authored by Kangjie Lu <kjlu [at]> on Fri Mar 22 22:51:06 2019 -0400. The commit for this change in Linux stable tree is ed8b1a1 (patch) which is from upstream commit e08f076. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream e08f076.

media: vpss: fix a potential NULL pointer dereference

[ Upstream commit e08f0761234def47961d3252eac09ccedfe4c6a0 ]

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

Signed-off-by: Kangjie Lu <>
Acked-by: Lad, Prabhakar <>
Reviewed-by: Mukesh Ojha <>
Signed-off-by: Mauro Carvalho Chehab <>
Signed-off-by: Sasha Levin <>

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/media/platform/davinci/vpss.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/davinci/vpss.c b/drivers/media/platform/davinci/vpss.c
index fce86f1..c2c6898 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -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;
+   }
             VPSS_CLK_CTRL_DACCLKEN, oper_cfg.vpss_regs_base2);

Leave a Reply

Your email address will not be published. Required fields are marked *