Skip to contentSkip to conversation

i2c: acpi: Free resource list at appropriate time

PATCH In review Andy Shevchenko 2 participants 2 messages Jun 17

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/i2c/i2c-core-acpi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/i2c-core-acpi.c +4 -1
index e5fddacae9a4..c13cf29a9092 100644
@@ -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;
Signature · 1 line
2.50.1