linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [resend, PATCH v1 1/1] platform/x86: int3472: Don't leak reference on error
@ 2022-10-04 12:26 Andy Shevchenko
  2022-10-04 14:11 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2022-10-04 12:26 UTC (permalink / raw)
  To: Hans de Goede, Andy Shevchenko, platform-driver-x86, linux-kernel
  Cc: Daniel Scally, Mark Gross, Rafael J. Wysocki, linux-acpi

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@linux.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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [resend, PATCH v1 1/1] platform/x86: int3472: Don't leak reference on error
  2022-10-04 12:26 [resend, PATCH v1 1/1] platform/x86: int3472: Don't leak reference on error Andy Shevchenko
@ 2022-10-04 14:11 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2022-10-04 14:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans de Goede, platform-driver-x86, linux-kernel, Daniel Scally,
	Mark Gross, Rafael J. Wysocki, linux-acpi

On Tue, Oct 4, 2022 at 2:26 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> 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@linux.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;
>  }
>
> --

Applied, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-04 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 12:26 [resend, PATCH v1 1/1] platform/x86: int3472: Don't leak reference on error Andy Shevchenko
2022-10-04 14:11 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).