trace-cmd: Fixed small memory leak in plugin code

Thanks again to valgrind in finding some memory leaks in the plugin
code.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/trace-util.c b/trace-util.c
index d5be6ed..520f800 100644
--- a/trace-util.c
+++ b/trace-util.c
@@ -154,7 +154,7 @@
 	char *plugin;
 	void *handle;
 	pevent_plugin_load_func func;
-	int ret;
+	int ret = -1;
 
 	plugin = malloc_or_die(strlen(path) + strlen(file) + 2);
 
@@ -166,19 +166,22 @@
 	if (!handle) {
 		warning("cound not load plugin '%s'\n%s\n",
 			plugin, dlerror());
-		return -1;
+		goto out;
 	}
 
 	func = dlsym(handle, PEVENT_PLUGIN_LOADER_NAME);
 	if (!func) {
 		warning("cound not find func '%s' in plugin '%s'\n%s\n",
 			PEVENT_PLUGIN_LOADER_NAME, plugin, dlerror());
-		return -1;
+		goto out;
 	}
 
 	printf("registering plugin: %s\n", plugin);
 	ret = func(pevent);
 
+ out:
+	free(plugin);
+
 	/* dlclose ?? */
 	return ret;
 }
@@ -262,5 +265,7 @@
 
  fail:
 	free(path);
+	closedir(dir);
+
 	return -1;
 }