Skip to content

Commit

Permalink
platform/x86: int3472: Don't leak reference on error
Browse files Browse the repository at this point in the history
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: 43cf369 ("platform/x86: int3472: Support multiple clock consumers")
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
andy-shev authored and rafaeljw committed Oct 4, 2022
1 parent 9388076 commit 800b8ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/platform/x86/intel/int3472/tps68470.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 800b8ee

Please sign in to comment.