lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250407084829.5755-1-hanchunchao@inspur.com>
Date: Mon, 7 Apr 2025 16:48:29 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <ming.qian@....com>, <eagle.zhou@....com>, <mchehab@...nel.org>,
	<hverkuil@...all.nl>, <shijie.qin@....com>
CC: <linux-media@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Charles Han
	<hanchunchao@...pur.com>
Subject: [PATCH] media: amphion: fix potential NULL deref in vpu_core_parse_dt

memremap()  may return a NULL pointer, dereferencing it
without NULL check may lead to NULL dereference.
Add a NULL check for core->fw.virt and core->rpc.virt.

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Signed-off-by: Charles Han <hanchunchao@...pur.com>
---
 drivers/media/platform/amphion/vpu_core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/media/platform/amphion/vpu_core.c b/drivers/media/platform/amphion/vpu_core.c
index 8df85c14ab3f..7ad27051aaa9 100644
--- a/drivers/media/platform/amphion/vpu_core.c
+++ b/drivers/media/platform/amphion/vpu_core.c
@@ -587,6 +587,16 @@ static int vpu_core_parse_dt(struct vpu_core *core, struct device_node *np)
 
 	core->fw.virt = memremap(core->fw.phys, core->fw.length, MEMREMAP_WC);
 	core->rpc.virt = memremap(core->rpc.phys, core->rpc.length, MEMREMAP_WC);
+	if (!core->fw.virt || !core->rpc.virt) {
+		dev_err(core->dev, "memremap error\n");
+		if (core->fw.virt)
+			memunmap(core->fw.virt);
+		if (core->rpc.virt)
+			memunmap(core->rpc.virt);
+		of_node_put(node);
+		return -ENOMEM;
+	}
+
 	memset(core->rpc.virt, 0, core->rpc.length);
 
 	ret = vpu_iface_check_memory_region(core, core->rpc.phys, core->rpc.length);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ