From patchwork Thu Jul 28 13:27:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Denk X-Patchwork-Id: 107251 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 7E7EDB6F18 for ; Thu, 28 Jul 2011 23:27:39 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0FBE12809F; Thu, 28 Jul 2011 15:27:38 +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 bILuQ2N-k-8P; Thu, 28 Jul 2011 15:27:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B14C0280A0; Thu, 28 Jul 2011 15:27:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 204AD280A0 for ; Thu, 28 Jul 2011 15:27:32 +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 LY-a8HFv-x0G for ; Thu, 28 Jul 2011 15:27:30 +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 mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by theia.denx.de (Postfix) with ESMTP id 219AD2809F for ; Thu, 28 Jul 2011 15:27:29 +0200 (CEST) Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id B24071C1D9F5; Thu, 28 Jul 2011 15:27:28 +0200 (CEST) X-Auth-Info: vhIi6redIBG8bli2W0TOhYOkUrvQ99/BQ6s83P4XMY8= Received: from diddl.denx.de (host-80-81-18-216.customer.m-online.net [80.81.18.216]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 8A2AA1C000A2; Thu, 28 Jul 2011 15:27:28 +0200 (CEST) Received: from gemini.denx.de (gemini.denx.de [10.0.0.2]) by diddl.denx.de (Postfix) with ESMTP id 62D10C913109; Thu, 28 Jul 2011 15:27:28 +0200 (CEST) Received: by gemini.denx.de (Postfix, from userid 500) id 459E215794D5; Thu, 28 Jul 2011 15:27:28 +0200 (CEST) From: Wolfgang Denk To: u-boot@lists.denx.de Date: Thu, 28 Jul 2011 15:27:22 +0200 Message-Id: <1311859642-5153-1-git-send-email-wd@denx.de> X-Mailer: git-send-email 1.7.6 In-Reply-To: <4DFC750F.7050605@teamboyce.co.uk> References: <4DFC750F.7050605@teamboyce.co.uk> Cc: Stefan Roese Subject: [U-Boot] [PATCH] ubifs: Fix bad free() sequence in ubifs_finddir() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 Free private_data member element before freeing file structure. This was causing malloc to crash. Also remove unnecessary variable assigments as file structure gets free'd as well. Signed-off-by: Rod Boyce Signed-off-by: Wolfgang Denk Cc: Stefan Roese --- As Rod appears to have disappeared I took the frredom to jump in and fix this. - wd fs/ubifs/ubifs.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 5a5c739..61f70b2 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -360,6 +360,8 @@ out: return err; } + if (file->private_data) + kfree(file->private_data); if (file) free(file); if (dentry) @@ -367,10 +369,6 @@ out: if (dir) free(dir); - if (file->private_data) - kfree(file->private_data); - file->private_data = NULL; - file->f_pos = 2; return 0; }