aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-29 13:51:36 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-29 14:10:00 -0500
commitc359b2f7fc57ad9bf1adc006ea42ac2bfa652d0f (patch)
tree3003936e730875fdcbb5ec6e43475c951356aaac
parent397292ce2da1208e15a1902eda41213f92228420 (diff)
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>
-rw-r--r--trace-util.c11
1 files changed, 8 insertions, 3 deletions
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 @@ static int load_plugin(struct pevent *pevent,
154 char *plugin; 154 char *plugin;
155 void *handle; 155 void *handle;
156 pevent_plugin_load_func func; 156 pevent_plugin_load_func func;
157 int ret; 157 int ret = -1;
158 158
159 plugin = malloc_or_die(strlen(path) + strlen(file) + 2); 159 plugin = malloc_or_die(strlen(path) + strlen(file) + 2);
160 160
@@ -166,19 +166,22 @@ static int load_plugin(struct pevent *pevent,
166 if (!handle) { 166 if (!handle) {
167 warning("cound not load plugin '%s'\n%s\n", 167 warning("cound not load plugin '%s'\n%s\n",
168 plugin, dlerror()); 168 plugin, dlerror());
169 return -1; 169 goto out;
170 } 170 }
171 171
172 func = dlsym(handle, PEVENT_PLUGIN_LOADER_NAME); 172 func = dlsym(handle, PEVENT_PLUGIN_LOADER_NAME);
173 if (!func) { 173 if (!func) {
174 warning("cound not find func '%s' in plugin '%s'\n%s\n", 174 warning("cound not find func '%s' in plugin '%s'\n%s\n",
175 PEVENT_PLUGIN_LOADER_NAME, plugin, dlerror()); 175 PEVENT_PLUGIN_LOADER_NAME, plugin, dlerror());
176 return -1; 176 goto out;
177 } 177 }
178 178
179 printf("registering plugin: %s\n", plugin); 179 printf("registering plugin: %s\n", plugin);
180 ret = func(pevent); 180 ret = func(pevent);
181 181
182 out:
183 free(plugin);
184
182 /* dlclose ?? */ 185 /* dlclose ?? */
183 return ret; 186 return ret;
184} 187}
@@ -262,5 +265,7 @@ int trace_load_plugins(struct pevent *pevent)
262 265
263 fail: 266 fail:
264 free(path); 267 free(path);
268 closedir(dir);
269
265 return -1; 270 return -1;
266} 271}