Skip to contentSkip to conversation

irqchip/riscv-rpmi-sysmsi: Fix mailbox channel leak in rpmi_sysmsi_probe()

PATCH Applied Felix Gu 5 participants 5 messages Mar 15 – Mar 24

Subsystems (4)
lore
Share & tools
lore

Felix Gu

author
#0 lore raw

PATCH 1/1 irqchip/riscv-rpmi-sysmsi: Fix mailbox channel leak in rpmi_sysmsi_probe()

When riscv_acpi_get_gsi_info() fails, the mailbox channel previously requested via mbox_request_channel() is not freed. Add the missing mbox_free_channel() call to prevent the resource leak.

Fixes 4752b0cfbc37 ("irqchip/riscv-rpmi-sysmsi: Add ACPI support")
---
 drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/irqchip/irq-riscv-rpmi-sysmsi.c +1 -0
index 5c74c561ce31..612f3972f7af 100644
@@ -250,6 +250,7 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
 		rc = riscv_acpi_get_gsi_info(fwnode, &priv->gsi_base, &id,
 					     &nr_irqs, NULL);
 		if (rc) {
+			mbox_free_channel(priv->chan);
 			dev_err(dev, "failed to find GSI mapping\n");
 			return rc;
 		}

---
base-commit: b84a0ebe421ca56995ff78b66307667b62b3a900
change-id: 20260315-sysmsi-f6254f65701f

Best regards,

Signature · 1 line
Felix Gu <[email protected]>
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Felix Gu

When riscv_acpi_get_gsi_info() fails, the mailbox channel previously requested via mbox_request_channel() is not freed. Add the missing mbox_free_channel() call to prevent the resource leak.

Fixes 4752b0cfbc37 ("irqchip/riscv-rpmi-sysmsi: Add ACPI support")
---
 drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/irqchip/irq-riscv-rpmi-sysmsi.c +0 -0
index 5c74c561ce31..612f3972f7af 100644

drivers/irqchip/irq-riscv-rpmi-sysmsi.c static int rpmi_sysmsi_probe(struct platform_device *pdev) · line 256

Quoted 7 lines
drivers/irqchip/irq-riscv-rpmi-sysmsi.c +1 -0
@@ -250,6 +250,7 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
                rc = riscv_acpi_get_gsi_info(fwnode, &priv->gsi_base, &id,
                                             &nr_irqs, NULL);
                if (rc) {
+                       mbox_free_channel(priv->chan);
                        dev_err(dev, "failed to find GSI mapping\n");
                        return rc;
                }
#2 lore raw
In reply to Felix Gu
Quoted 3 lines

When riscv_acpi_get_gsi_info() fails, the mailbox channel previously requested via mbox_request_channel() is not freed. Add the missing mbox_free_channel() call to prevent the resource leak.

How do you think about to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v7.0-rc3/source/drivers/mailbox/mailbox.c#L465-L496
https://elixir.bootlin.com/linux/v7.0-rc3/source/drivers/irqchip/irq-riscv-rpmi-sysmsi.c#L210-L307

Were any source code analysis tools involved here?

See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v7.0-rc3#n34

Regards,
Markus

merge bot Applied
#3 lore raw
In reply to Felix Gu
The 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:     76f0930d6e809234904cf9f0f5f42ee6c1dc694e
Gitweb:        https://git.kernel.org/tip/76f0930d6e809234904cf9f0f5f42ee6c1dc694e
Author:        Felix Gu <[email protected]>
AuthorDate:    Sun, 15 Mar 2026 15:17:54 +08:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 17 Mar 2026 11:16:15 +01:00

irqchip/riscv-rpmi-sysmsi: Fix mailbox channel leak in rpmi_sysmsi_probe()

When riscv_acpi_get_gsi_info() fails, the mailbox channel previously requested via mbox_request_channel() is not freed. Add the missing mbox_free_channel() call to prevent the resource leak.

Fixes 4752b0cfbc37 ("irqchip/riscv-rpmi-sysmsi: Add ACPI support")
---
 drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/irqchip/irq-riscv-rpmi-sysmsi.c +1 -0
index 5c74c56..612f397 100644
@@ -250,6 +250,7 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev)
 		rc = riscv_acpi_get_gsi_info(fwnode, &priv->gsi_base, &id,
 					     &nr_irqs, NULL);
 		if (rc) {
+			mbox_free_channel(priv->chan);
 			dev_err(dev, "failed to find GSI mapping\n");
 			return rc;
 		}
#4 lore raw
In reply to Felix Gu
This patch was applied to riscv/linux.git (for-next) by Thomas Gleixner <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (for-next) by Thomas Gleixner <[email protected]>:

Quoted 8 lines · On Sun, 15 Mar 2026 15:17:54 +0800 you wrote:

When riscv_acpi_get_gsi_info() fails, the mailbox channel previously requested via mbox_request_channel() is not freed. Add the missing mbox_free_channel() call to prevent the resource leak.

Fixes 4752b0cfbc37 ("irqchip/riscv-rpmi-sysmsi: Add ACPI support")

[...]

Here is the summary with links:
- irqchip/riscv-rpmi-sysmsi: Fix mailbox channel leak in rpmi_sysmsi_probe()

    https://git.kernel.org/riscv/c/76f0930d6e80

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html