diff --git a/CHANGES b/CHANGES index 1235218f..7ce02044 100644 --- a/CHANGES +++ b/CHANGES @@ -2,8 +2,10 @@ lm_sensors CHANGES file ----------------------- SVN HEAD + Library: Fix a memory leak on error Module i2c-piix4: Add ATI SB700 support (2.6 backport) + 2.10.4 (20070716) File doc/vid: Update the sysfs paths, update the chip lists File i2c-dev.h: Support I2C block reads with specified length diff --git a/lib/sysfs.c b/lib/sysfs.c index bbb2b735..26c0ac05 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -21,6 +21,7 @@ #define _GNU_SOURCE #include +#include #include #include #include @@ -83,8 +84,10 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) sensors_sysfs_mount, entry.name.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)) @@ -101,11 +104,16 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) entry.name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; entry.name.bus = SENSORS_CHIP_NAME_BUS_PCI; } else - return -SENSORS_ERR_PARSE; + goto exit_free; sensors_add_proc_chips(&entry); return 0; + +exit_free: + free(entry.name.prefix); + free(entry.name.busname); + return -SENSORS_ERR_PARSE; } /* returns 0 if successful, !0 otherwise */