From patchwork Tue Sep 17 01:31:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 275348 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3E6A52C0106 for ; Tue, 17 Sep 2013 11:32:43 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLk9U-0002pY-9X; Tue, 17 Sep 2013 01:32:28 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLk9S-0006RJ-Jo; Tue, 17 Sep 2013 01:32:26 +0000 Received: from mail-ob0-f171.google.com ([209.85.214.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLk9Q-0006Pc-Qv for linux-mtd@lists.infradead.org; Tue, 17 Sep 2013 01:32:25 +0000 Received: by mail-ob0-f171.google.com with SMTP id wm4so4723692obc.30 for ; Mon, 16 Sep 2013 18:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=41Vbnbb1eCARz/kBF8O/4ML6S+wqs0GQk39QOrAYIt8=; b=zS7+7CZM2AFa2/ZOiO7jCgP0OxT/ExJSmoLo7YsgL9zYrE8YyaE4eDy7+QB+kLK2TU 6p8u6j+wU41yDzJhXDLdpfrI44si8RUBGxkHK8iWYX2DE31v77GWG5TY/MDBvYjKZ/wb ayANORn3I9r6/CRVlY4cN9Ah2ns2wbNH0MVKKpdMcge3Kyh8uIL/wHP3rg3q1D94rAZn oQG6XBD8c5kZgnVEtZQl7niinAS6y4x+Yvz9k5p9gDro553wCRWaTAI7mWw641f4RSnd Kp6BcMQcdVDUcUShj4qUJ0XR+cVDFt7jgYDFOCuEeZTyR7uPCZFsDxVv3u8dPU138aMp QjFg== X-Received: by 10.182.246.39 with SMTP id xt7mr4149559obc.16.1379381520322; Mon, 16 Sep 2013 18:32:00 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id s9sm34492525obu.4.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Sep 2013 18:31:59 -0700 (PDT) From: Brian Norris To: David Woodhouse Subject: [PATCH] mtd: nand: fix memory leak in ONFI extended parameter page Date: Mon, 16 Sep 2013 18:31:52 -0700 Message-Id: <1379381512-2007-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.8.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130916_213224_920196_CA3E221D X-CRM114-Status: GOOD ( 15.04 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.171 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Huang Shijie , Brian Norris , linux-mtd@lists.infradead.org, Linux Kernel , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This fixes a memory leak in the ONFI support code for detecting the required ECC levels from this commit: commit 6dcbe0cdd83fb5f77be4f44c9e06c535281c375a Author: Huang Shijie Date: Wed May 22 10:28:27 2013 +0800 mtd: get the ECC info from the Extended Parameter Page In the success case, we never freed the 'ep' buffer. Also, this fixes an oversight in the same commit where we (harmlessly) freed the NULL pointer. Signed-off-by: Brian Norris Cc: Huang Shijie Acked-by: Huang Shijie --- David, if there are no objections, can you send this to Linus for 3.12? If this doesn't make it into 3.12, then it will be -stable material. drivers/mtd/nand/nand_base.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index d4578a1..00022b4 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2869,10 +2869,8 @@ static int nand_flash_detect_ext_param_page(struct mtd_info *mtd, len = le16_to_cpu(p->ext_param_page_length) * 16; ep = kmalloc(len, GFP_KERNEL); - if (!ep) { - ret = -ENOMEM; - goto ext_out; - } + if (!ep) + return -ENOMEM; /* Send our own NAND_CMD_PARAM. */ chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1); @@ -2920,7 +2918,7 @@ static int nand_flash_detect_ext_param_page(struct mtd_info *mtd, } pr_info("ONFI extended param page detected.\n"); - return 0; + ret = 0; ext_out: kfree(ep);