[PATCH] remoteproc: qcom_wcnss: fix NULL check on devm_ioremap_wc()
From: Elkin Cruz
Date: Fri Nov 20 2026 - 14:21:00 EST
devm_ioremap_wc() returns NULL on mapping failure rather than an
ERR_PTR(). Checking IS_ERR(wcnss->mem_region) lets NULL slip through as
success and would return 0 via PTR_ERR(NULL) even if triggered.
Check !wcnss->mem_region and return -ENOMEM on failure.
Fixes: f9b888599418 ("remoteproc: qcom_wcnss: Fix reserved region mapping failure")
Signed-off-by: Elkin Cruz <elkin@xxxxxxxxxx>
---
I am trying out a new Clang static analysis linter for ERR_PTR/NULL
handling, and it flagged this code as possibly buggy. The findings were triaged
and fixed with an AI coding assistant, then checked against linux-next (not
runtime-tested on hardware).
Thanks,
Elkin
drivers/remoteproc/qcom_wcnss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
index 02f38fe29f20..abe0ab320d03 100644
--- a/drivers/remoteproc/qcom_wcnss.c
+++ b/drivers/remoteproc/qcom_wcnss.c
@@ -541,9 +541,9 @@ static int wcnss_alloc_memory_region(struct qcom_wcnss *wcnss)
wcnss->mem_phys = wcnss->mem_reloc = res.start;
wcnss->mem_size = resource_size(&res);
wcnss->mem_region = devm_ioremap_wc(wcnss->dev, wcnss->mem_phys, wcnss->mem_size);
- if (IS_ERR(wcnss->mem_region)) {
+ if (!wcnss->mem_region) {
dev_err(wcnss->dev, "unable to map memory region: %pR\n", &res);
- return PTR_ERR(wcnss->mem_region);
+ return -ENOMEM;
}
return 0;
--
2.56.1.750.gf70dc682cf-goog