From patchwork Wed Mar 18 23:38:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek X-Patchwork-Id: 12993 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2INdZ00024422 for ; Wed, 18 Mar 2009 23:39:35 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id BC04361A339; Wed, 18 Mar 2009 19:39:35 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n2INdSig002320 for ; Wed, 18 Mar 2009 19:39:28 -0400 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2INdSQ4026323 for ; Wed, 18 Mar 2009 19:39:28 -0400 Received: from mars.virtualiron.com (host-216-57-134-2.customer.veroxity.net [216.57.134.2]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n2INdCRE002903 for ; Wed, 18 Mar 2009 19:39:12 -0400 Received: by mars.virtualiron.com (Postfix, from userid 1179) id 30CDB204005; Wed, 18 Mar 2009 19:38:09 -0400 (EDT) From: Konrad Rzeszutek To: dm-devel@redhat.com Date: Wed, 18 Mar 2009 19:38:07 -0400 Message-Id: <1237419489-3303-3-git-send-email-konrad@virtualiron.com> In-Reply-To: <1237419489-3303-2-git-send-email-konrad@virtualiron.com> References: <1237419489-3303-1-git-send-email-konrad@virtualiron.com> <1237419489-3303-2-git-send-email-konrad@virtualiron.com> X-RedHat-Spam-Score: -0.048 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] [PATCH] Unload prio and checkers libraries during shutdown. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com From: Konrad Rzeszutek 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(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index 5132081..19d0781 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -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); } } diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index e735250..b610e6b 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -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 **); diff --git a/libmultipath/prio.c b/libmultipath/prio.c index c9d2873..4c5f4f0 100644 --- a/libmultipath/prio.c +++ b/libmultipath/prio.c @@ -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); } } diff --git a/libmultipath/prio.h b/libmultipath/prio.h index 491e6fc..fc9277f 100644 --- a/libmultipath/prio.h +++ b/libmultipath/prio.h @@ -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 *); diff --git a/multipath/main.c b/multipath/main.c index 8b38a6e..e60b9bc 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -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, diff --git a/multipathd/main.c b/multipathd/main.c index 36aa93c..7de41a0 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -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()