ACPI: irq: Fix incorrect return value in acpi_register_gsi()
authorSunil V L <sunilvl@ventanamicro.com>
Mon, 16 Oct 2023 17:09:39 +0000 (22:39 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 18 Oct 2023 11:11:04 +0000 (13:11 +0200)
acpi_register_gsi() should return a negative value in case of failure.

Currently, it returns the return value from irq_create_fwspec_mapping().
However, irq_create_fwspec_mapping() returns 0 for failure. Fix the
issue by returning -EINVAL if irq_create_fwspec_mapping() returns zero.

Fixes: d44fa3d46079 ("ACPI: Add support for ResourceSource/IRQ domain mapping")
Cc: 4.11+ <stable@vger.kernel.org> # 4.11+
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
[ rjw: Rename a new local variable ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/irq.c

index c2c786e..1687483 100644 (file)
@@ -57,6 +57,7 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger,
                      int polarity)
 {
        struct irq_fwspec fwspec;
+       unsigned int irq;
 
        fwspec.fwnode = acpi_get_gsi_domain_id(gsi);
        if (WARN_ON(!fwspec.fwnode)) {
@@ -68,7 +69,11 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger,
        fwspec.param[1] = acpi_dev_get_irq_type(trigger, polarity);
        fwspec.param_count = 2;
 
-       return irq_create_fwspec_mapping(&fwspec);
+       irq = irq_create_fwspec_mapping(&fwspec);
+       if (!irq)
+               return -EINVAL;
+
+       return irq;
 }
 EXPORT_SYMBOL_GPL(acpi_register_gsi);