]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: acpi: Free resource list at appropriate time
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 17 Jun 2026 09:24:06 +0000 (11:24 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 17 Jun 2026 13:58:30 +0000 (14:58 +0100)
We do unneeded "double free" (emptying an empty list) in one case.

This is not a critical issue at all, the fix just makes code robust
against any possible future changes in the flow.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260617092406.2649384-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c

index ab37b50bbf79c5cd4382868e9a255be4d1df4ad2..d7e584afa301a4bac222b0b3148f2a4aa88f7c8d 100644 (file)
@@ -2979,12 +2979,12 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,
        INIT_LIST_HEAD(&resource_list);
        ret = acpi_dev_get_resources(adev, &resource_list,
                                     acpi_spi_add_resource, &lookup);
-       acpi_dev_free_resource_list(&resource_list);
-
        if (ret < 0)
                /* Found SPI in _CRS but it points to another controller */
                return ERR_PTR(ret);
 
+       acpi_dev_free_resource_list(&resource_list);
+
        if (!lookup.max_speed_hz &&
            ACPI_SUCCESS(acpi_get_parent(adev->handle, &parent_handle)) &&
            device_match_acpi_handle(lookup.ctlr->dev.parent, parent_handle)) {