remoteproc: qcom_wcnss: fix NULL check on devm_ioremap_wc()
Subsystems (2)
PATCH 1/1 remoteproc: qcom_wcnss: fix NULL check on devm_ioremap_wc()
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 <[email protected]>
---
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(-)
drivers/remoteproc/qcom_wcnss.c +2 -2
@@ -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 ;
Signature · 1 line
2.56.1.750.gf70dc682cf-goog