diff --git a/CHANGES b/CHANGES index 112a298c..fd221732 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ SVN HEAD Delete procfs and sysctl support (Linux 2.4) Delete all remnants of algorithm names Drop all the chip-specific support + Fix a memory leak on error Makefile: Drop the package and version targets Man page sensors.conf.5: Update the chip statement section Programs doc/*: Delete, obsolete diff --git a/lib/sysfs.c b/lib/sysfs.c index c97e249e..f507deb8 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -235,8 +235,10 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) sensors_sysfs_mount, entry.chip.bus); if ((bus_attr = sysfs_open_attribute(bus_path))) { - if (sysfs_read_attribute(bus_attr)) - return -SENSORS_ERR_PARSE; + if (sysfs_read_attribute(bus_attr)) { + sysfs_close_attribute(bus_attr); + goto exit_free; + } if (bus_attr->value && !strncmp(bus_attr->value, "ISA ", 4)) @@ -253,13 +255,18 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) entry.chip.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; entry.chip.bus = SENSORS_CHIP_NAME_BUS_PCI; } else - return -SENSORS_ERR_PARSE; + goto exit_free; if (sensors_read_dynamic_chip(&entry, dev) < 0) - return -SENSORS_ERR_PARSE; + goto exit_free; sensors_add_proc_chips(&entry); return 0; + +exit_free: + free(entry.chip.prefix); + free(entry.chip.busname); + return -SENSORS_ERR_PARSE; } /* returns 0 if successful, !0 otherwise */