@@ -27,7 +27,6 @@ char * checker_state_name (int i)
int init_checkers (void)
{
- INIT_LIST_HEAD(&checkers);
if (!add_checker(DEFAULT_CHECKER))
return 1;
return 0;
@@ -35,12 +34,12 @@ int init_checkers (void)
struct checker * alloc_checker (void)
{
- return zalloc(sizeof(struct checker));
+ return MALLOC(sizeof(struct checker));
}
void free_checker (struct checker * c)
{
- free(c);
+ FREE(c);
}
void cleanup_checkers (void)
@@ -50,7 +49,7 @@ void cleanup_checkers (void)
list_for_each_entry_safe(checker_loop, checker_temp, &checkers, node) {
list_del(&checker_loop->node);
- free(checker_loop);
+ free_checker(checker_loop);
}
}
@@ -111,6 +111,7 @@ struct checker {
char * checker_state_name (int);
int init_checkers (void);
+void cleanup_checkers (void);
struct checker * add_checker (char *);
struct checker * checker_lookup (char *);
int checker_init (struct checker *, void **);
@@ -11,7 +11,6 @@ static LIST_HEAD(prioritizers);
int init_prio (void)
{
- INIT_LIST_HEAD(&prioritizers);
if (!add_prio(DEFAULT_PRIO))
return 1;
return 0;
@@ -19,12 +18,12 @@ int init_prio (void)
struct prio * alloc_prio (void)
{
- return zalloc(sizeof(struct prio));
+ return MALLOC(sizeof(struct prio));
}
void free_prio (struct prio * p)
{
- free(p);
+ FREE(p);
}
void cleanup_prio(void)
@@ -34,7 +33,7 @@ void cleanup_prio(void)
list_for_each_entry_safe(prio_loop, prio_temp, &prioritizers, node) {
list_del(&prio_loop->node);
- free(prio_loop);
+ free_prio(prio_loop);
}
}
@@ -42,6 +42,7 @@ struct prio {
};
int init_prio (void);
+void cleanup_prio (void);
struct prio * add_prio (char *);
struct prio * prio_lookup (char *);
int prio_getprio (struct prio *, struct path *);
@@ -443,6 +443,8 @@ out:
dm_lib_release();
dm_lib_exit();
+ cleanup_prio();
+ cleanup_checkers();
/*
* Freeing config must be done after dm_lib_exit(), because
* the logging function (dm_write_log()), which is called there,
@@ -1389,6 +1389,8 @@ child (void * param)
dm_lib_release();
dm_lib_exit();
+ cleanup_prio();
+ cleanup_checkers();
/*
* Freeing config must be done after condlog() and dm_lib_exit(),
* because logging functions like dlog() and dm_write_log()
From: Konrad Rzeszutek <konrad@mars.virtualiron.com> Our statup sequence is 'load_config', 'init_checkers', and 'init_prio'. Both init_* functions reset the list of prio and checkers, which is unfortunate as in load_config, depending on the multipat.conf, would load prio and checker libraries. This results in double-loading of the libraries and a memory leak. --- libmultipath/checkers.c | 7 +++---- libmultipath/checkers.h | 1 + libmultipath/prio.c | 7 +++---- libmultipath/prio.h | 1 + multipath/main.c | 2 ++ multipathd/main.c | 2 ++ 6 files changed, 12 insertions(+), 8 deletions(-)