LinuxTV Patchwork media: vpss: fix a potential NULL pointer dereference

login
register
mail settings
Submitter Kangjie Lu
Date March 9, 2019, 6:53 a.m.
Message ID <20190309065351.1184-1-kjlu@umn.edu>
Download mbox | patch
Permalink /patch/54979/
State New
Delegated to: Hans Verkuil
Headers show

Comments

Kangjie Lu - March 9, 2019, 6:53 a.m.
In case ioremap fails, the fix returns -ENOMEM to avoid NULL
pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/media/platform/davinci/vpss.c | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/drivers/media/platform/davinci/vpss.c b/drivers/media/platform/davinci/vpss.c
index 19cf6853411e..f7beed2de9cb 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -518,6 +518,9 @@  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))
+		return -ENOMEM;
+
 	writel(VPSS_CLK_CTRL_VENCCLKEN |
 		     VPSS_CLK_CTRL_DACCLKEN, oper_cfg.vpss_regs_base2);
 

Privacy Policy