mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-24 12:04:33 +00:00
Clean up if something goes wrong during initialization. Otherwise
we're leaking memory. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4988 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
6d5292cce4
commit
58b3284058
2 files changed
+11
-5
No files matched your search
@@ -3,6 +3,7 @@ lm-sensors CHANGES file
|
||||
|
||||
SVN HEAD
|
||||
libsensors: Add a default configuration file
|
||||
Fix memory leaks on initialization error
|
||||
sensord: Reload config on SIGHUP rather than automatically
|
||||
No default configuration file name
|
||||
sensors: Fix file handle leak on library initialization error
|
||||
|
||||
+10
-5
@@ -39,28 +39,33 @@ int sensors_init(FILE *input)
|
||||
return -SENSORS_ERR_KERNEL;
|
||||
if ((res = sensors_read_sysfs_bus()) ||
|
||||
(res = sensors_read_sysfs_chips()))
|
||||
return res;
|
||||
goto exit_cleanup;
|
||||
|
||||
res = -SENSORS_ERR_PARSE;
|
||||
if (input) {
|
||||
if (sensors_scanner_init(input) ||
|
||||
sensors_yyparse())
|
||||
return -SENSORS_ERR_PARSE;
|
||||
goto exit_cleanup;
|
||||
} else {
|
||||
/* No configuration provided, use default */
|
||||
input = fopen(DEFAULT_CONFIG_FILE, "r");
|
||||
if (!input)
|
||||
return -SENSORS_ERR_PARSE;
|
||||
goto exit_cleanup;
|
||||
if (sensors_scanner_init(input) ||
|
||||
sensors_yyparse()) {
|
||||
fclose(input);
|
||||
return -SENSORS_ERR_PARSE;
|
||||
goto exit_cleanup;
|
||||
}
|
||||
fclose(input);
|
||||
}
|
||||
|
||||
if ((res = sensors_substitute_busses()))
|
||||
return res;
|
||||
goto exit_cleanup;
|
||||
return 0;
|
||||
|
||||
exit_cleanup:
|
||||
sensors_cleanup();
|
||||
return res;
|
||||
}
|
||||
|
||||
static void free_chip_name(sensors_chip_name *name)
|
||||
|
||||
Reference in new issue
Block a user