Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Andy Shevchenko and committed by
Rafael J. Wysocki
800b8eec 9388076b

+3 -3
+3 -3
drivers/platform/x86/intel/int3472/tps68470.c
··· 128 128 for_each_acpi_consumer_dev(adev, consumer) { 129 129 sensor_name = devm_kasprintf(dev, GFP_KERNEL, I2C_DEV_NAME_FORMAT, 130 130 acpi_dev_name(consumer)); 131 - if (!sensor_name) 131 + if (!sensor_name) { 132 + acpi_dev_put(consumer); 132 133 return -ENOMEM; 134 + } 133 135 134 136 (*clk_pdata)->consumers[i].consumer_dev_name = sensor_name; 135 137 i++; 136 138 } 137 - 138 - acpi_dev_put(consumer); 139 139 140 140 return n_consumers; 141 141 }