aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisono Tomohiro <misono.tomohiro@jp.fujitsu.com>2020-06-25 13:32:42 +0900
committerPaul Gortmaker <paul.gortmaker@windriver.com>2020-07-24 16:24:26 -0400
commit83e497ec8490c3c18bcbdd790e3a492e1c836b0f (patch)
treef4baa1bc0091e923a47591bb7f68d723394501d2
parentc543c30b7cd19983e3d48f84ad54a85837bbf4ba (diff)
downloadlinux-yocto-83e497ec8490c3c18bcbdd790e3a492e1c836b0f.tar.gz
linux-yocto-83e497ec8490c3c18bcbdd790e3a492e1c836b0f.tar.bz2
linux-yocto-83e497ec8490c3c18bcbdd790e3a492e1c836b0f.zip
hwmon: (acpi_power_meter) Fix potential memory leak in acpi_power_meter_add()
commit 8b97f9922211c44a739c5cbd9502ecbb9f17f6d1 upstream. Although it rarely happens, we should call free_capabilities() if error happens after read_capabilities() to free allocated strings. Fixes: de584afa5e188 ("hwmon driver for ACPI 4.0 power meters") Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> Link: https://lore.kernel.org/r/20200625043242.31175-1-misono.tomohiro@jp.fujitsu.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--drivers/hwmon/acpi_power_meter.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 4cf25458f0b9..740ac0a1b726 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -883,7 +883,7 @@ static int acpi_power_meter_add(struct acpi_device *device)
res = setup_attrs(resource);
if (res)
- goto exit_free;
+ goto exit_free_capability;
resource->hwmon_dev = hwmon_device_register(&device->dev);
if (IS_ERR(resource->hwmon_dev)) {
@@ -896,6 +896,8 @@ static int acpi_power_meter_add(struct acpi_device *device)
exit_remove:
remove_attrs(resource);
+exit_free_capability:
+ free_capabilities(resource);
exit_free:
kfree(resource);
exit: