[PATCH] irqchip/aslint-sswi: request IO memory resource

Vladimir Kondratiev posted 1 patch 2 months ago
drivers/irqchip/irq-aclint-sswi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] irqchip/aslint-sswi: request IO memory resource
Posted by Vladimir Kondratiev 2 months ago
Make an aclint_sswi instance visible in the resource list,
i.e. /proc/iomem

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
---
 drivers/irqchip/irq-aclint-sswi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-aclint-sswi.c b/drivers/irqchip/irq-aclint-sswi.c
index 93e28e9f281f..0723f77a4307 100644
--- a/drivers/irqchip/irq-aclint-sswi.c
+++ b/drivers/irqchip/irq-aclint-sswi.c
@@ -109,7 +109,7 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
 	if (!is_of_node(fwnode))
 		return -EINVAL;
 
-	reg = of_iomap(to_of_node(fwnode), 0);
+	reg = of_io_request_and_map(to_of_node(fwnode), 0, NULL);
 	if (!reg)
 		return -ENOMEM;
 

base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
-- 
2.43.0
Re: [PATCH] irqchip/aslint-sswi: request IO memory resource
Posted by Chris Mason 3 weeks, 2 days ago
On Tue,  9 Dec 2025 16:23:33 +0200 Vladimir Kondratiev <vladimir.kondratiev@mobileye.com> wrote:

> Make an aclint_sswi instance visible in the resource list,
> i.e. /proc/iomem
> 

Hi everyone,

I ran tip master through my AI review prompts, and this one was flagged.
This is a lot of words for NULL vs ERR_PTR, but it looks right to me:

> diff --git a/drivers/irqchip/irq-aclint-sswi.c b/drivers/irqchip/irq-aclint-sswi.c
> index fee30f3bc5ac2..325501f34a9bc 100644
> --- a/drivers/irqchip/irq-aclint-sswi.c
> +++ b/drivers/irqchip/irq-aclint-sswi.c
> @@ -109,7 +109,7 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
>  	if (!is_of_node(fwnode))
>  		return -EINVAL;
>
> -	reg = of_iomap(to_of_node(fwnode), 0);
> +	reg = of_io_request_and_map(to_of_node(fwnode), 0, NULL);
>  	if (!reg)
>  		return -ENOMEM;

Should this error check be updated? of_iomap() returns NULL on failure,
but of_io_request_and_map() returns IOMEM_ERR_PTR() on failure which is
non-NULL.

When of_io_request_and_map() fails, the condition (!reg) will be false
and the function continues with an invalid ERR_PTR value. This gets passed
to aclint_sswi_parse_irq() which stores (reg + offset) into per_cpu
sswi_cpu_regs, leading to a crash when IPIs are later sent.

Other callers of of_io_request_and_map() in drivers/irqchip/ use IS_ERR()
for the error check. For example, sun6i_r_intc_init() in irq-sun6i-r.c:

    base = of_io_request_and_map(node, 0, NULL);
    if (IS_ERR(base)) {
        pr_err("%pOF: Failed to map MMIO region\n", node);
        return PTR_ERR(base);
    }
Re: [PATCH] irqchip/aslint-sswi: request IO memory resource
Posted by Thomas Gleixner 3 weeks, 1 day ago
On Fri, Jan 16 2026 at 04:42, Chris Mason wrote:
> On Tue,  9 Dec 2025 16:23:33 +0200 Vladimir Kondratiev <vladimir.kondratiev@mobileye.com> wrote:
>
>> Make an aclint_sswi instance visible in the resource list,
>> i.e. /proc/iomem
>> 
>
> Hi everyone,
>
> I ran tip master through my AI review prompts, and this one was flagged.
> This is a lot of words for NULL vs ERR_PTR, but it looks right to me:
>
>> diff --git a/drivers/irqchip/irq-aclint-sswi.c b/drivers/irqchip/irq-aclint-sswi.c
>> index fee30f3bc5ac2..325501f34a9bc 100644
>> --- a/drivers/irqchip/irq-aclint-sswi.c
>> +++ b/drivers/irqchip/irq-aclint-sswi.c
>> @@ -109,7 +109,7 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
>>  	if (!is_of_node(fwnode))
>>  		return -EINVAL;
>>
>> -	reg = of_iomap(to_of_node(fwnode), 0);
>> +	reg = of_io_request_and_map(to_of_node(fwnode), 0, NULL);
>>  	if (!reg)
>>  		return -ENOMEM;
>
> Should this error check be updated? of_iomap() returns NULL on failure,
> but of_io_request_and_map() returns IOMEM_ERR_PTR() on failure which is
> non-NULL.
>
> When of_io_request_and_map() fails, the condition (!reg) will be false
> and the function continues with an invalid ERR_PTR value. This gets passed
> to aclint_sswi_parse_irq() which stores (reg + offset) into per_cpu
> sswi_cpu_regs, leading to a crash when IPIs are later sent.
>
> Other callers of of_io_request_and_map() in drivers/irqchip/ use IS_ERR()
> for the error check. For example, sun6i_r_intc_init() in irq-sun6i-r.c:
>
>     base = of_io_request_and_map(node, 0, NULL);
>     if (IS_ERR(base)) {
>         pr_err("%pOF: Failed to map MMIO region\n", node);
>         return PTR_ERR(base);
>     }

That's correct. Does anyone care to send a patch?

Thanks,

        tglx
[PATCH] irqchip/aslint-sswi: fix error checking
Posted by Vladimir Kondratiev 3 weeks ago
of_io_request_and_map() returns IOMEM_ERR_PTR() on failure which is
non-NULL.

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
---
 drivers/irqchip/irq-aclint-sswi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-aclint-sswi.c b/drivers/irqchip/irq-aclint-sswi.c
index 325501f34a9b..ca06efd86fa1 100644
--- a/drivers/irqchip/irq-aclint-sswi.c
+++ b/drivers/irqchip/irq-aclint-sswi.c
@@ -110,8 +110,10 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
 		return -EINVAL;
 
 	reg = of_io_request_and_map(to_of_node(fwnode), 0, NULL);
-	if (!reg)
-		return -ENOMEM;
+	if (IS_ERR(reg)) {
+		pr_err("%pfwP: Failed to map MMIO region\n", fwnode);
+		return PTR_ERR(reg);
+	}
 
 	/* Parse SSWI setting */
 	rc = aclint_sswi_parse_irq(fwnode, reg);
-- 
2.43.0
[tip: irq/drivers] irqchip/aslint-sswi: Fix error check of of_io_request_and_map() result
Posted by tip-bot2 for Vladimir Kondratiev 3 weeks ago
The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     a384f2ed886d4417d50fdad78aaf1ccf870d62e6
Gitweb:        https://git.kernel.org/tip/a384f2ed886d4417d50fdad78aaf1ccf870d62e6
Author:        Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
AuthorDate:    Sun, 18 Jan 2026 10:28:43 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Sun, 18 Jan 2026 14:39:18 +01:00

irqchip/aslint-sswi: Fix error check of of_io_request_and_map() result

of_io_request_and_map() returns IOMEM_ERR_PTR() on failure which is
non-NULL.

Fixes: 8a7f030df897 ("irqchip/aslint-sswi: Request IO memory resource")
Reported-by: Chris Mason <clm@meta.com>
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260118082843.2786630-1-vladimir.kondratiev@mobileye.com
Closes: https://lore.kernel.org/all/20260116124257.78357-1-clm@meta.com
---
 drivers/irqchip/irq-aclint-sswi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-aclint-sswi.c b/drivers/irqchip/irq-aclint-sswi.c
index 325501f..ca06efd 100644
--- a/drivers/irqchip/irq-aclint-sswi.c
+++ b/drivers/irqchip/irq-aclint-sswi.c
@@ -110,8 +110,10 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
 		return -EINVAL;
 
 	reg = of_io_request_and_map(to_of_node(fwnode), 0, NULL);
-	if (!reg)
-		return -ENOMEM;
+	if (IS_ERR(reg)) {
+		pr_err("%pfwP: Failed to map MMIO region\n", fwnode);
+		return PTR_ERR(reg);
+	}
 
 	/* Parse SSWI setting */
 	rc = aclint_sswi_parse_irq(fwnode, reg);
[tip: irq/drivers] irqchip/aslint-sswi: Fix error check of of_io_request_and_map() result
Posted by tip-bot2 for Vladimir Kondratiev 3 weeks ago
The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     d9fbb5a1550516faa0d737ea2749e90d2b36d523
Gitweb:        https://git.kernel.org/tip/d9fbb5a1550516faa0d737ea2749e90d2b36d523
Author:        Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
AuthorDate:    Sun, 18 Jan 2026 10:28:43 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Sun, 18 Jan 2026 10:42:02 +01:00

irqchip/aslint-sswi: Fix error check of of_io_request_and_map() result

of_io_request_and_map() returns IOMEM_ERR_PTR() on failure which is
non-NULL.

Fixes: 8a7f030df897 ("irqchip/aslint-sswi: Request IO memory resource")
Reported-by: Chris Mason <clm@meta.com>
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260118082843.2786630-1-vladimir.kondratiev@mobileye.com
Closes: https://lore.kernel.org/all/20260116124257.78357-1-clm@meta.com
---
 drivers/irqchip/irq-aclint-sswi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-aclint-sswi.c b/drivers/irqchip/irq-aclint-sswi.c
index 325501f..ca06efd 100644
--- a/drivers/irqchip/irq-aclint-sswi.c
+++ b/drivers/irqchip/irq-aclint-sswi.c
@@ -110,8 +110,10 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
 		return -EINVAL;
 
 	reg = of_io_request_and_map(to_of_node(fwnode), 0, NULL);
-	if (!reg)
-		return -ENOMEM;
+	if (IS_ERR(reg)) {
+		pr_err("%pfwP: Failed to map MMIO region\n", fwnode);
+		return PTR_ERR(reg);
+	}
 
 	/* Parse SSWI setting */
 	rc = aclint_sswi_parse_irq(fwnode, reg);
[tip: irq/drivers] irqchip/aslint-sswi: Request IO memory resource
Posted by tip-bot2 for Vladimir Kondratiev 1 month, 3 weeks ago
The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     8a7f030df89746842094334cdf55114d0fbb0234
Gitweb:        https://git.kernel.org/tip/8a7f030df89746842094334cdf55114d0fbb0234
Author:        Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
AuthorDate:    Tue, 09 Dec 2025 16:23:33 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 15 Dec 2025 22:44:31 +01:00

irqchip/aslint-sswi: Request IO memory resource

Make an aclint_sswi instance visible in the resource list, i.e. /proc/iomem

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://patch.msgid.link/20251209142336.1061606-1-vladimir.kondratiev@mobileye.com
---
 drivers/irqchip/irq-aclint-sswi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-aclint-sswi.c b/drivers/irqchip/irq-aclint-sswi.c
index fee30f3..325501f 100644
--- a/drivers/irqchip/irq-aclint-sswi.c
+++ b/drivers/irqchip/irq-aclint-sswi.c
@@ -109,7 +109,7 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
 	if (!is_of_node(fwnode))
 		return -EINVAL;
 
-	reg = of_iomap(to_of_node(fwnode), 0);
+	reg = of_io_request_and_map(to_of_node(fwnode), 0, NULL);
 	if (!reg)
 		return -ENOMEM;