mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-30 13:00:30 +00:00
Fix memory leaks in sensord revealed by valgrind.
The leak in daemonize() is harmless, we're about to exit anyway. Fix it still to make valgrind happy. The leak in do_features() is real, as the function is called periodically by the daemon, for all actions. If the intervals at set low and the system has many sensors, the leak could be significant, maybe 150 kB/day. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6025 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
9e144ca2a5
commit
8aa001900f
3 files changed
+19
-10
No files matched your search
@@ -4,6 +4,7 @@ lm-sensors CHANGES file
|
||||
SVN HEAD
|
||||
libsensors: Added support for new sysfs attributes
|
||||
Change sysfs detection to survive upcoming kernel changes
|
||||
sensord: Fix memory leaks revealed by valgrind
|
||||
sensors: Added support for new sysfs attributes
|
||||
Display both instantaneous and average power if available.
|
||||
Report thermal sensor type 1 as CPU diode
|
||||
|
||||
+13
-9
@@ -132,14 +132,7 @@ static int do_features(const sensors_chip_name *chip,
|
||||
const FeatureDescriptor *feature, int action)
|
||||
{
|
||||
char *label;
|
||||
int alrm, beep;
|
||||
|
||||
label = sensors_get_label(chip, feature->feature);
|
||||
if (!label) {
|
||||
sensorLog(LOG_ERR, "Error getting sensor label: %s/%s",
|
||||
chip->prefix, feature->feature->name);
|
||||
return -1;
|
||||
}
|
||||
int alrm, beep, ret;
|
||||
|
||||
alrm = get_flag(chip, feature->alarmNumber);
|
||||
if (alrm == -1)
|
||||
@@ -151,7 +144,18 @@ static int do_features(const sensors_chip_name *chip,
|
||||
if (beep == -1)
|
||||
return -1;
|
||||
|
||||
return get_features(chip, feature, action, label, alrm, beep);
|
||||
label = sensors_get_label(chip, feature->feature);
|
||||
if (!label) {
|
||||
sensorLog(LOG_ERR, "Error getting sensor label: %s/%s",
|
||||
chip->prefix, feature->feature->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = get_features(chip, feature, action, label, alrm, beep);
|
||||
|
||||
free(label);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int doKnownChip(const sensors_chip_name *chip,
|
||||
|
||||
@@ -204,7 +204,11 @@ static void daemonize(void)
|
||||
} else if (pid != 0) {
|
||||
fprintf(file, "%d\n", pid);
|
||||
fclose(file);
|
||||
unloadLib();
|
||||
|
||||
freeChips();
|
||||
if (unloadLib())
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user