netapp plugin: Don't access a struct after freeing it.
[collectd.git] / src / netapp.c
index aab30e5..ab01b74 100644 (file)
@@ -384,11 +384,11 @@ static void free_host_config (host_config_t *hc) /* {{{ */
        free_cfg_volume_usage (hc->cfg_volume_usage);
        free_cfg_system (hc->cfg_system);
 
-       sfree (hc);
-
        if (hc->srv != NULL)
                na_server_close (hc->srv);
 
+       sfree (hc);
+
        free_host_config (next);
 } /* }}} void free_host_config */
 
@@ -2402,10 +2402,19 @@ static int cna_read (void) { /* {{{ */
        return 0;
 } /* }}} int cna_read */
 
+static int cna_shutdown (void) /* {{{ */
+{
+       free_host_config (global_host_config);
+       global_host_config = NULL;
+
+       return (0);
+} /* }}} int cna_shutdown */
+
 void module_register(void) {
        plugin_register_complex_config("netapp", cna_config);
        plugin_register_init("netapp", cna_init);
        plugin_register_read("netapp", cna_read);
+       plugin_register_shutdown("netapp", cna_shutdown);
 }
 
 /* vim: set sw=2 ts=2 noet fdm=marker : */