Fix a memory leak in sensors_read_one_sysfs_chip() when an error occurs.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4635 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2007-07-21 08:40:26 +00:00
1 parent 7429bc0191
commit 5611ffe6d1
2 files changed
+13 -3

No files matched your search

+2
View File
@@ -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
+11 -3
View File
@@ -21,6 +21,7 @@
#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <sysfs/libsysfs.h>
@@ -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 */