irqchip/sifive-plic: Fix error codes
Subsystems (4)
PATCH 1/1 irqchip/sifive-plic: Fix error codes
Set error to -ENOMEM if kcalloc() fails or if irq_domain_add_linear() fails inside of plic_probe().
--- drivers/irqchip/irq-sifive-plic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/irqchip/irq-sifive-plic.c +6 -2
@@ -626,8 +626,10 @@ static int plic_probe(struct fwnode_handle *fwnode) handler->enable_save =kcalloc (DIV_ROUND_UP (nr_irqs,32 ),sizeof (*handler->enable_save),GFP_KERNEL ); -if (!handler->enable_save) +if (!handler->enable_save) { + error = -ENOMEM ; goto fail_cleanup_contexts; + } done:for (hwirq =1 ; hwirq <= nr_irqs; hwirq++) {plic_toggle (handler, hwirq,0 );
@@ -639,8 +641,10 @@ static int plic_probe(struct fwnode_handle *fwnode) priv->irqdomain =irq_domain_create_linear (fwnode, nr_irqs +1 , &plic_irqdomain_ops, priv); -if (WARN_ON (!priv->irqdomain)) +if (WARN_ON (!priv->irqdomain)) { + error = -ENOMEM ; goto fail_cleanup_contexts; + }/* * We can have multiple PLIC instances so setup global state
---
base-commit: 6804f0edbe7747774e6ae60f20cec4ee3ad7c187
change-id: 20240903-correct_error_codes_sifive_plic-4611f59291df
Signature · 1 line
- Charlie
Hi Charlie,
Quoted 7 lines · Charlie Jenkins
Set error to
-ENOMEMifkcalloc()fails or ifirq_domain_add_linear()fails inside ofplic_probe().Signed-off-by Charlie Jenkins <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>
I found the following Fixes tag:
Quoted 9 lines
--- drivers/irqchip/irq-sifive-plic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/irqchip/irq-sifive-plic.c +0
-0
drivers/irqchip/irq-sifive-plic.c static int plic_probe(struct fwnode_handle *fwnode) · line 630
Quoted 6 lines
drivers/irqchip/irq-sifive-plic.c +2
-1@@ -626,8 +626,10 @@ static int plic_probe(struct fwnode_handle *fwnode) handler->enable_save =kcalloc (DIV_ROUND_UP (nr_irqs,32 ),sizeof (*handler->enable_save),GFP_KERNEL ); -if (!handler->enable_save) +if (!handler->enable_save) { + error = -ENOMEM ;
This is correct.
drivers/irqchip/irq-sifive-plic.c static int plic_probe(struct fwnode_handle *fwnode) · line 645
Quoted 12 lines
drivers/irqchip/irq-sifive-plic.c +3
-1goto fail_cleanup_contexts; + } done:for (hwirq =1 ; hwirq <= nr_irqs; hwirq++) {plic_toggle (handler, hwirq,0 );@@ -639,8 +641,10 @@ static int plic_probe(struct fwnode_handle *fwnode) priv->irqdomain =irq_domain_create_linear (fwnode, nr_irqs +1 , &plic_irqdomain_ops, priv); -if (WARN_ON (!priv->irqdomain)) +if (WARN_ON (!priv->irqdomain)) { + error = -ENOMEM ;
Here though I found drivers that return either ENODEV (https://elixir.bootlin.com/linux/v6.11/source/drivers/irqchip/irq-gic.c#L1210) or ENOMEM (https://elixir.bootlin.com/linux/v6.11/source/drivers/irqchip/irq-imx-mu-msi.c#L229).
Before the commit I mentioned above, we used to return ENOMEM. IMHO it's not a big deal as long as we return something different from 0 in that case, I just mention it if someone thinks differently.
You can add:
And I would also add:
Thanks,
Alex
Quoted 9 lines
drivers/irqchip/irq-sifive-plic.c +1
-1goto fail_cleanup_contexts; + }/* * We can have multiple PLIC instances so setup global state --- base-commit:
6804f0edbe7747774e6ae60f20cec4ee3ad7c187
change-id: 20240903-correct_error_codes_sifive_plic-4611f59291df
Quoted 4 lines · Charlie Jenkins
Set error to
-ENOMEMifkcalloc()fails or ifirq_domain_add_linear()fails inside ofplic_probe().
Like Alex mentioned, please include a Fixes tag.
Quoted 4 lines
Signed-off-by Charlie Jenkins <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>
LGTM.
Regards,
Anup
Quoted 40 lines
--- drivers/irqchip/irq-sifive-plic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/irqchip/irq-sifive-plic.c +6
-3@@ -626,8 +626,10 @@ static int plic_probe(struct fwnode_handle *fwnode) handler->enable_save =kcalloc (DIV_ROUND_UP (nr_irqs,32 ),sizeof (*handler->enable_save),GFP_KERNEL ); -if (!handler->enable_save) +if (!handler->enable_save) { + error = -ENOMEM ; goto fail_cleanup_contexts; + } done:for (hwirq =1 ; hwirq <= nr_irqs; hwirq++) {plic_toggle (handler, hwirq,0 );@@ -639,8 +641,10 @@ static int plic_probe(struct fwnode_handle *fwnode) priv->irqdomain =irq_domain_create_linear (fwnode, nr_irqs +1 , &plic_irqdomain_ops, priv); -if (WARN_ON (!priv->irqdomain)) +if (WARN_ON (!priv->irqdomain)) { + error = -ENOMEM ; goto fail_cleanup_contexts; + }/* * We can have multiple PLIC instances so setup global state --- base-commit:
6804f0edbe7747774e6ae60f20cec4ee3ad7c187
change-id: 20240903-correct_error_codes_sifive_plic-4611f59291df --
- Charlie
[tip: irq/urgent] irqchip/sifive-plic: Return error code on failure
In reply to Charlie JenkinsThe following commit has been merged into the irq/urgent branch of tip:
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: 6eabf656048d904d961584de2e1d45bc0854f9fb Gitweb: https://git.kernel.org/tip/6eabf656048d904d961584de2e1d45bc0854f9fb Author: Charlie Jenkins <[email protected]> AuthorDate: Tue, 03 Sep 2024 16:36:19 -07:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 02 Oct 2024 15:15:33 +02:00
irqchip/sifive-plic: Return error code on failure
Set error to -ENOMEM if kcalloc() fails or if irq_domain_add_linear() fails inside of plic_probe() instead of returning 0.
--- drivers/irqchip/irq-sifive-plic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/irqchip/irq-sifive-plic.c +6 -2
@@ -626,8 +626,10 @@ static int plic_probe(struct fwnode_handle *fwnode) handler->enable_save =kcalloc (DIV_ROUND_UP (nr_irqs,32 ),sizeof (*handler->enable_save),GFP_KERNEL ); -if (!handler->enable_save) +if (!handler->enable_save) { + error = -ENOMEM ; goto fail_cleanup_contexts; + } done:for (hwirq =1 ; hwirq <= nr_irqs; hwirq++) {plic_toggle (handler, hwirq,0 );
@@ -639,8 +641,10 @@ done: priv->irqdomain =irq_domain_create_linear (fwnode, nr_irqs +1 , &plic_irqdomain_ops, priv); -if (WARN_ON (!priv->irqdomain)) +if (WARN_ON (!priv->irqdomain)) { + error = -ENOMEM ; goto fail_cleanup_contexts; + }/* * We can have multiple PLIC instances so setup global state
This patch was applied to riscv/linux.git (fixes) by Thomas Gleixner <[email protected]>:
Hello:
This patch was applied to riscv/linux.git (fixes)
by Thomas Gleixner <[email protected]>:
Quoted 9 lines · On Tue, 03 Sep 2024 16:36:19 -0700 you wrote:
Set error to
-ENOMEMifkcalloc()fails or ifirq_domain_add_linear()fails inside ofplic_probe().Signed-off-by Charlie Jenkins <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>[...]
Here is the summary with links:
- irqchip/sifive-plic: Fix error codes
https://git.kernel.org/riscv/c/6eabf656048d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html