summaryrefslogtreecommitdiff
path: root/lib/init.c
diff options
context:
space:
mode:
authorkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2007-10-25 09:51:19 +0000
committerkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2007-10-25 09:51:19 +0000
commitd3f2d432be62baa6c85a23e5716ac88f3cd68f8e (patch)
tree5e3105925e0a86550641958802725a98c5912040 /lib/init.c
parentc74070567411f7903c5aa9e48bae33558ea55c14 (diff)
downloadlm-sensors-d3f2d432be62baa6c85a23e5716ac88f3cd68f8e.tar.gz
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
Diffstat (limited to 'lib/init.c')
-rw-r--r--lib/init.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/init.c b/lib/init.c
index 15ad3a5a..01c68a88 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -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)