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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251215074125.2089-1-vulab@iscas.ac.cn>
Date: Mon, 15 Dec 2025 15:41:25 +0800
From: Haotian Zhang <vulab@...as.ac.cn>
To: andersson@...nel.org,
	konradybcio@...nel.org
Cc: linux-arm-msm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Haotian Zhang <vulab@...as.ac.cn>
Subject: [PATCH] soc: qcom: cmd-db: Fix memory leak in cmd_db_dev_probe error path

If cmd_db_magic_matches() fails after memremap() succeeds, the function
returns -EINVAL without unmapping the memory region, causing a
potential resource leak.

Add memunmap() call and set cmd_db_header to NULL before returning error
to properly clean up the mapped memory region.

Fixes: 312416d9171a ("drivers: qcom: add command DB driver")
Signed-off-by: Haotian Zhang <vulab@...as.ac.cn>
---
 drivers/soc/qcom/cmd-db.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index ae66c2623d25..50adf5249826 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -358,6 +358,8 @@ static int cmd_db_dev_probe(struct platform_device *pdev)
 
 	if (!cmd_db_magic_matches(cmd_db_header)) {
 		dev_err(&pdev->dev, "Invalid Command DB Magic\n");
+		memunmap(cmd_db_header);
+		cmd_db_header = NULL;
 		return -EINVAL;
 	}
 
-- 
2.50.1.windows.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ