2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-31 06:15:15 +00:00

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

git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4636 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2007-07-21 08:44:31 +00:00
parent 834cd70e14
commit f302998cd2
2 changed files with 12 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ SVN HEAD
Delete procfs and sysctl support (Linux 2.4) Delete procfs and sysctl support (Linux 2.4)
Delete all remnants of algorithm names Delete all remnants of algorithm names
Drop all the chip-specific support Drop all the chip-specific support
Fix a memory leak on error
Makefile: Drop the package and version targets Makefile: Drop the package and version targets
Man page sensors.conf.5: Update the chip statement section Man page sensors.conf.5: Update the chip statement section
Programs doc/*: Delete, obsolete Programs doc/*: Delete, obsolete

View File

@@ -235,8 +235,10 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev)
sensors_sysfs_mount, entry.chip.bus); sensors_sysfs_mount, entry.chip.bus);
if ((bus_attr = sysfs_open_attribute(bus_path))) { if ((bus_attr = sysfs_open_attribute(bus_path))) {
if (sysfs_read_attribute(bus_attr)) if (sysfs_read_attribute(bus_attr)) {
return -SENSORS_ERR_PARSE; sysfs_close_attribute(bus_attr);
goto exit_free;
}
if (bus_attr->value if (bus_attr->value
&& !strncmp(bus_attr->value, "ISA ", 4)) && !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.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn;
entry.chip.bus = SENSORS_CHIP_NAME_BUS_PCI; entry.chip.bus = SENSORS_CHIP_NAME_BUS_PCI;
} else } else
return -SENSORS_ERR_PARSE; goto exit_free;
if (sensors_read_dynamic_chip(&entry, dev) < 0) if (sensors_read_dynamic_chip(&entry, dev) < 0)
return -SENSORS_ERR_PARSE; goto exit_free;
sensors_add_proc_chips(&entry); sensors_add_proc_chips(&entry);
return 0; return 0;
exit_free:
free(entry.chip.prefix);
free(entry.chip.busname);
return -SENSORS_ERR_PARSE;
} }
/* returns 0 if successful, !0 otherwise */ /* returns 0 if successful, !0 otherwise */