* [lm-sensors] [PATCH 1/3] sensord: Fix memory leaks revealed by valgrind
@ 2012-03-03 21:25 Jean Delvare
2012-03-04 6:42 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Jean Delvare @ 2012-03-03 21:25 UTC (permalink / raw)
To: lm-sensors
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.
---
prog/sensord/sense.c | 22 +++++++++++++---------
prog/sensord/sensord.c | 6 +++++-
2 files changed, 18 insertions(+), 10 deletions(-)
--- lm-sensors.orig/prog/sensord/sensord.c 2009-06-20 11:58:07.000000000 +0200
+++ lm-sensors/prog/sensord/sensord.c 2012-03-02 20:30:48.050146653 +0100
@@ -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);
}
--- lm-sensors.orig/prog/sensord/sense.c 2009-11-05 10:20:28.000000000 +0100
+++ lm-sensors/prog/sensord/sense.c 2012-03-02 20:56:17.677852135 +0100
@@ -132,14 +132,7 @@ static int do_features(const sensors_chi
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_chi
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,
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [lm-sensors] [PATCH 1/3] sensord: Fix memory leaks revealed by valgrind
2012-03-03 21:25 [lm-sensors] [PATCH 1/3] sensord: Fix memory leaks revealed by valgrind Jean Delvare
@ 2012-03-04 6:42 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2012-03-04 6:42 UTC (permalink / raw)
To: lm-sensors
On Sat, Mar 03, 2012 at 04:25:36PM -0500, Jean Delvare wrote:
> 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.
> ---
> prog/sensord/sense.c | 22 +++++++++++++---------
> prog/sensord/sensord.c | 6 +++++-
> 2 files changed, 18 insertions(+), 10 deletions(-)
>
Nice catch series looks good.
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-04 6:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-03 21:25 [lm-sensors] [PATCH 1/3] sensord: Fix memory leaks revealed by valgrind Jean Delvare
2012-03-04 6:42 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.