From patchwork Mon Feb 22 16:40:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: niam X-Patchwork-Id: 45971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B1C47B7CED for ; Tue, 23 Feb 2010 03:42:25 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NjbKs-0004H4-9V; Mon, 22 Feb 2010 16:40:42 +0000 Received: from fg-out-1718.google.com ([72.14.220.157]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NjbKk-0004EJ-IW for linux-mtd@lists.infradead.org; Mon, 22 Feb 2010 16:40:39 +0000 Received: by fg-out-1718.google.com with SMTP id e21so1105932fga.0 for ; Mon, 22 Feb 2010 08:40:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=phNH/kc4ZV1pVApDh7ECeoffq5iuj+keyggsFTGLlfg=; b=JY9PCGYe9mpAWotGsYr1hC5d6utk+AdC+Uy50hFvJTSRDV1A3PF6531Z9mfwlR4RDj 3pqNN872UPYSPDWnsRwtGa14nSw4+o0riCMyYbex6zunaz+/D3fuOH1eywFo8ifPiBeL VwERu+P/I8sbsslYS4wCU8WGOFHs1gOnJmSOI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=k3GzGAdBVbtlw5AHkrxiS+v0/vOjtdAt59r2fg18FP/2EYPZrOQWng785dV1yf6sth iJ/UCoKhjpUuX2D5/+ztarsucZGFejfuamrMQjXQUZeD+pisgDvjL+CPtvdYXwyO4UN0 LD6dOBlVM1I9XPGeiOAjS2yCuQawFIgbjZzok= MIME-Version: 1.0 Received: by 10.216.89.137 with SMTP id c9mr908248wef.228.1266856832068; Mon, 22 Feb 2010 08:40:32 -0800 (PST) In-Reply-To: References: From: niam Date: Mon, 22 Feb 2010 18:40:11 +0200 Message-ID: Subject: [PATCH] jffs2: fix memory leak if the sector was successfully erased To: David Woodhouse , Joe Perches , Joakim Tjernlund , linux-mtd@lists.infradead.org X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100222_114034_767545_C12F54F5 X-CRM114-Status: GOOD ( 10.73 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: linux-kernel@vger.kernel.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Resending patch to proper people/mailing list. Memory allocated for erase instruction is not freed if the sector was successfully erased. Signed-off-by: Dmytro Milinevskyy ---  fs/jffs2/erase.c |    4 +++-  1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index b47679b..c0a5604 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c @@ -74,8 +74,10 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,        ((struct erase_priv_struct *)instr->priv)->c = c;        ret = c->mtd->erase(c->mtd, instr); -       if (!ret) +       if (!ret) { +        kfree(instr);                return; +    }        bad_offset = instr->fail_addr;        kfree(instr);