diff mbox series

kernel-shark: Fix potential segfault in free_plugin()

Message ID 20220114092107.100521-1-y.karadz@gmail.com (mailing list archive)
State Accepted
Commit 1104f52c7eeea3512bb33370c3ac549e9c4e3af2
Headers show
Series kernel-shark: Fix potential segfault in free_plugin() | expand

Commit Message

Yordan Karadzhov Jan. 14, 2022, 9:21 a.m. UTC
The 'handle' field is not guaranteed to be initialized, hence a check
is required before closing it.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/libkshark-plugin.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/libkshark-plugin.c b/src/libkshark-plugin.c
index 09886ce..2eb3b4a 100644
--- a/src/libkshark-plugin.c
+++ b/src/libkshark-plugin.c
@@ -219,9 +219,10 @@  void kshark_free_draw_handler_list(struct kshark_draw_handler *handlers)
 /** Close and free this plugin. */
 static void free_plugin(struct kshark_plugin_list *plugin)
 {
-	dlclose(plugin->handle);
+	if (plugin->handle)
+		dlclose(plugin->handle);
 
-	if (plugin->process_interface){
+	if (plugin->process_interface) {
 		free(plugin->process_interface->name);
 		free(plugin->process_interface);
 	}