[lvm-devel] [PATCH 2/7] Fix resouces leak in error path

Zdenek Kabelac zkabelac at redhat.com
Mon Mar 29 15:27:20 UTC 2010


If the error path of _register_for_event() calls _free_thread_status()
we need to call _lib_put().
To make thing simplier moving this _lib_put() into common error path code.

Signed-off-by: Zdenek Kabelac <zkabelac at redhat.com>
---
 daemons/dmeventd/dmeventd.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 37122c9..f4b664b 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -243,8 +243,10 @@ static struct thread_status *_alloc_thread_status(struct message_data *data,
 	return ret;
 }
 
+static void _lib_put(struct dso_data *data);
 static void _free_thread_status(struct thread_status *thread)
 {
+	_lib_put(thread->dso_data);
 	if (thread->current_task)
 		dm_task_destroy(thread->current_task);
 	dm_free(thread->device.uuid);
@@ -1481,7 +1483,6 @@ static void _cleanup_unused_threads(void)
 		if (thread->status == DM_THREAD_DONE) {
 			dm_list_del(l);
 			pthread_join(thread->thread, NULL);
-			_lib_put(thread->dso_data);
 			_free_thread_status(thread);
 		}
 	}
-- 
1.7.0.1




More information about the lvm-devel mailing list