From patchwork Tue Aug 28 12:00:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 180447 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id EAC782C0282 for ; Tue, 28 Aug 2012 22:00:37 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 35BA028086; Tue, 28 Aug 2012 14:00:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LRJugcRZOhxP; Tue, 28 Aug 2012 14:00:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6B2A52807F; Tue, 28 Aug 2012 14:00:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F0A3B2807F for ; Tue, 28 Aug 2012 14:00:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qrvt9B6nPJFN for ; Tue, 28 Aug 2012 14:00:28 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mo-p05-ob.rzone.de (mo-p05-ob.rzone.de [81.169.146.182]) by theia.denx.de (Postfix) with ESMTPS id 43B722807E for ; Tue, 28 Aug 2012 14:00:27 +0200 (CEST) X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohdvpEkce+Ub4+ReKfHD+mB0GMrenTvA== X-RZG-CLASS-ID: mo05 Received: from ubuntu-2012.fritz.box (p57B950F5.dip.t-dialin.net [87.185.80.245]) by smtp.strato.de (josoe mo4) (RZmta 30.12 DYNA|AUTH) with ESMTPA id h0481do7SB39bu ; Tue, 28 Aug 2012 14:00:25 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Date: Tue, 28 Aug 2012 14:00:24 +0200 Message-Id: <1346155224-26630-1-git-send-email-sr@denx.de> X-Mailer: git-send-email 1.7.12 Subject: [U-Boot] [PATCH] ubifs: Fix memory leak in ubifs_finddir X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch fixes a memory leak in ubifs_finddir(). Signed-off-by: Stefan Roese Cc: dev.ma.dma@gmail.com --- fs/ubifs/ubifs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 604eb8f..c68802b 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -295,6 +295,7 @@ static int ubifs_finddir(struct super_block *sb, char *dirname, struct file *file; struct dentry *dentry; struct inode *dir; + int ret = 0; file = kzalloc(sizeof(struct file), 0); dentry = kzalloc(sizeof(struct dentry), 0); @@ -336,7 +337,8 @@ static int ubifs_finddir(struct super_block *sb, char *dirname, if ((strncmp(dirname, (char *)dent->name, nm.len) == 0) && (strlen(dirname) == nm.len)) { *inum = le64_to_cpu(dent->inum); - return 1; + ret = 1; + goto out_free; } /* Switch to the next entry */ @@ -355,11 +357,10 @@ static int ubifs_finddir(struct super_block *sb, char *dirname, } out: - if (err != -ENOENT) { + if (err != -ENOENT) ubifs_err("cannot find next direntry, error %d", err); - return err; - } +out_free: if (file->private_data) kfree(file->private_data); if (file) @@ -369,7 +370,7 @@ out: if (dir) free(dir); - return 0; + return ret; } static unsigned long ubifs_findfile(struct super_block *sb, char *filename)