]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf/arm-cmn: Fix incorrect error check for devm_ioremap()
authorChen Ni <nichen@iscas.ac.cn>
Thu, 26 Mar 2026 09:08:56 +0000 (17:08 +0800)
committerWill Deacon <will@kernel.org>
Thu, 26 Mar 2026 15:23:38 +0000 (15:23 +0000)
Check devm_ioremap() return value for NULL instead of ERR_PTR and return
-ENOMEM on failure. devm_ioremap() never returns ERR_PTR, using IS_ERR()
skips the error path and may cause a NULL pointer dereference.

Fixes: 5394396ff548 ("perf/arm-cmn: Stop claiming entire iomem region")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/arm-cmn.c

index 1ac91cda678019f8c21fd95dabf71b1f9f91bc20..9fe00d0f4deb3aa43c45b28390a79b8cd2f748ea 100644 (file)
@@ -2573,8 +2573,8 @@ static int arm_cmn_probe(struct platform_device *pdev)
 
        /* Map the whole region now, claim the DTCs once we've found them */
        cmn->base = devm_ioremap(cmn->dev, cfg->start, resource_size(cfg));
-       if (IS_ERR(cmn->base))
-               return PTR_ERR(cmn->base);
+       if (!cmn->base)
+               return -ENOMEM;
 
        rootnode = arm_cmn_get_root(cmn, cfg);
        if (rootnode < 0)