From patchwork Thu Sep 11 13:52:05 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 5343 Received: from john.hrz.tu-chemnitz.de (john.hrz.tu-chemnitz.de [134.109.132.2]) by open-mesh.net (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id m8BDuOVY032355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 11 Sep 2008 15:56:26 +0200 Received: from galba.hrz.tu-chemnitz.de ([134.109.133.156] helo=mailbox.hrz.tu-chemnitz.de) by john.hrz.tu-chemnitz.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1KdmaY-0006BJ-T8 for b.a.t.m.a.n@open-mesh.net; Thu, 11 Sep 2008 15:52:02 +0200 Received: from vpnclient-076.hrz.tu-chemnitz.de ([134.109.232.76] helo=sven-desktop) by mailbox.hrz.tu-chemnitz.de with smtp (Exim 4.69) (envelope-from ) id 1KdmaY-0008Qi-KW for b.a.t.m.a.n@open-mesh.net; Thu, 11 Sep 2008 15:52:02 +0200 Received: by sven-desktop (nbSMTP-1.00) for uid 1000 sven.eckelmann@gmx.de; Thu, 11 Sep 2008 15:52:06 +0200 (CEST) Date: Thu, 11 Sep 2008 15:52:05 +0200 From: Sven Eckelmann To: b.a.t.m.a.n@open-mesh.net Message-ID: <20080911135205.GA21654@sven-desktop.lazhur.ath.cx> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Scan-Signature: 46d95ba3376559e2858f4f05828cc033 Subject: [B.A.T.M.A.N.] [PATCH] kfree list nodes after deleting them from free_client_list in batgat X-BeenThere: b.a.t.m.a.n@open-mesh.net X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Sep 2008 13:56:26 -0000 list_del will only move the next pointer of the previous entry to the next entry and the do the same with the previous pointer of the next entry. The entry itself will not be touched. We allocated new memory for the list entry so we must free them or otherwise we would only leak memory and run out of it after enough connecting and leaving clients. Signed-off-by: Sven Eckelmann --- batman/linux/modules/gateway.c | 3 +++ batman/linux/modules/gateway24.c | 3 +++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/batman/linux/modules/gateway.c b/batman/linux/modules/gateway.c index 5786be8..e90be0b 100644 --- a/batman/linux/modules/gateway.c +++ b/batman/linux/modules/gateway.c @@ -148,6 +148,7 @@ void cleanup_module() if(entry->gw_client != NULL) { gw_client = entry->gw_client; list_del(&entry->list); + kfree(entry); kfree(gw_client); } @@ -267,6 +268,7 @@ static int batgat_ioctl( struct inode *inode, struct file *file, unsigned int cm if(entry->gw_client) { gw_client = entry->gw_client; list_del(&entry->list); + kfree(entry); kfree(gw_client); } @@ -653,6 +655,7 @@ static struct gw_client *get_ip_addr(struct sockaddr_in *client_addr) DBG("use free client from list"); gw_client = entry->gw_client; list_del(&entry->list); + kfree(entry); break; } diff --git a/batman/linux/modules/gateway24.c b/batman/linux/modules/gateway24.c index 44dfc0e..585fe85 100644 --- a/batman/linux/modules/gateway24.c +++ b/batman/linux/modules/gateway24.c @@ -129,6 +129,7 @@ void cleanup_module() if(entry->gw_client != NULL) { gw_client = entry->gw_client; list_del(&entry->list); + kfree(entry); kfree(gw_client); } @@ -251,6 +252,7 @@ static int batgat_ioctl( struct inode *inode, struct file *file, unsigned int cm gw_client = entry->gw_client; list_del(&entry->list); + kfree(entry); kfree(gw_client); } @@ -595,6 +597,7 @@ static struct gw_client *get_ip_addr(struct sockaddr_in *client_addr) printk(KERN_DEBUG "use free client from list"); gw_client = entry->gw_client; list_del(&entry->list); + kfree(entry); break; }