i2c: acpi: Free resource list at appropriate time

We do unneeded "double free" (emptying an empty list) in one case.
At the same time we shadow a real error code. Address them by
refactoring the code in question.

Both are not critical issues at all, they just make code robust
against any possible future changes in the flow.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260617092046.2649219-1-andriy.shevchenko@linux.intel.com
This commit is contained in:
Andy Shevchenko 2026-06-17 11:20:46 +02:00 committed by Andi Shyti
parent 9e9762e578
commit 20c3dcb1f4
No known key found for this signature in database
GPG Key ID: DA78056626D32D6E

View File

@ -168,9 +168,12 @@ static int i2c_acpi_do_lookup(struct acpi_device *adev,
INIT_LIST_HEAD(&resource_list);
ret = acpi_dev_get_resources(adev, &resource_list,
i2c_acpi_fill_info, lookup);
if (ret < 0)
return ret;
acpi_dev_free_resource_list(&resource_list);
if (ret < 0 || !info->addr)
if (!info->addr)
return -EINVAL;
return 0;