[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221004122636.61755-1-andriy.shevchenko@linux.intel.com>
Date: Tue, 4 Oct 2022 15:26:36 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Hans de Goede <hdegoede@...hat.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Daniel Scally <djrscally@...il.com>,
Mark Gross <markgross@...nel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, linux-acpi@...r.kernel.org
Subject: [resend, PATCH v1 1/1] platform/x86: int3472: Don't leak reference on error
The for_each_acpi_consumer_dev() takes a reference to the iterator
and if we break a loop we must drop that reference. This usually
happens when error handling is involved. However it's not the case
for skl_int3472_fill_clk_pdata().
Don't leak reference on error by dropping it properly.
Fixes: 43cf36974d76 ("platform/x86: int3472: Support multiple clock consumers")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
resent to include Rafael and linux-acpi@ to the Cc list
drivers/platform/x86/intel/int3472/tps68470.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/intel/int3472/tps68470.c b/drivers/platform/x86/intel/int3472/tps68470.c
index f83e9c393f31..5b8d1a9620a5 100644
--- a/drivers/platform/x86/intel/int3472/tps68470.c
+++ b/drivers/platform/x86/intel/int3472/tps68470.c
@@ -128,15 +128,15 @@ skl_int3472_fill_clk_pdata(struct device *dev, struct tps68470_clk_platform_data
for_each_acpi_consumer_dev(adev, consumer) {
sensor_name = devm_kasprintf(dev, GFP_KERNEL, I2C_DEV_NAME_FORMAT,
acpi_dev_name(consumer));
- if (!sensor_name)
+ if (!sensor_name) {
+ acpi_dev_put(consumer);
return -ENOMEM;
+ }
(*clk_pdata)->consumers[i].consumer_dev_name = sensor_name;
i++;
}
- acpi_dev_put(consumer);
-
return n_consumers;
}
--
2.35.1
Powered by blists - more mailing lists