From patchwork Tue May 2 00:04:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 757355 X-Patchwork-Delegate: computersforpeace@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wH1lL6H7xz9sNF for ; Tue, 2 May 2017 10:05:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ct9zeDDI"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hWYFov8k"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=aVh1wQRx+dUyah1c3cZk9NQgL7VNtnl3RPAMJw3dAZU=; b=Ct9 zeDDITjo0XLJ6z0VU0R6Wk0cbXSS/2CAnXB08hr1UD9OicO1t/qk4VNsOTqPjTmuXnsV10/M4jynK nAa9nqQ0tkToMu/m8hJDIrxTX6tB7noB0GSbj8cXXrOEqrQXKHa08c3efhGbx729WiCpW91lq3qHp LDwszGAjsPDKcr1XaVt/63HRXFxzDxAeLO9ETuyTzrPOt5nNbpd4TV+iFCMUqQEmlydzqHOM7YE2A sE2pSQbdJFy3RJ1hp/9R7vvzJcDWCYkERpz37rAhVeNSfN03vKiw0uQS4+bznMAqL2ZU/PF2GyMtV dpm5qa4VOTig4KKDB+52UpwL2C7ypLA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d5LJo-0001wD-6Y; Tue, 02 May 2017 00:05:28 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d5LJm-0001OV-4m for linux-mtd@lists.infradead.org; Tue, 02 May 2017 00:05:27 +0000 Received: by mail-pf0-x243.google.com with SMTP id g23so29729071pfj.1 for ; Mon, 01 May 2017 17:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xTul71BeoiCDZ1xm+sNsYvu0eOZePdAxO7HfPodAWEg=; b=hWYFov8kSQzMfXFvyrZxIBWE+edsM4ctsai21Xeltyo6WoSaWqyokRu7jfbx+eLcdj Q6acE37fYBYedUEchtI4VyszA2e3b2KLJ2zEZDGoDbONb3seaOz/tQY34Dzb8oB0aN/n nAjwU7qVl4gQcNsHvgLfz6WiGBvlxXZJUrFQZYSA7Vvkx3vFBXTTNtgSV5FBrCKdzeMS 876GYHlOhNFEaoALueCE9jHUweTBe2NWh45At3xtEsQ1L+KLInabrI7oIT3l1ZH/LnUx DxhQ/1imQGnKFGPdbSyhuu1r5PmwmKaJPgws3LPU/6+Iba7U/0ne0e9AfeeFZLdEGeW7 a8eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xTul71BeoiCDZ1xm+sNsYvu0eOZePdAxO7HfPodAWEg=; b=hlxjU0fYg9Cowh7S1C8XI9niPffz752G5T8RfdZiCMb5heevqv0JtsIIm2NfBU+qAD xWimNmq+Y3TIiuDl5A87WozDqeIO3L6FGB8QRIJPNY1WYW+zqrZ0QSiU7sn61S43+QIU yVjSTMYDmvMv3LENGN9jM14AIECkFcKm4OGfWlNzwdXZRcCpI0o++i/XGJlzmaU9XBer bVxyVShN7Uk+R+qtjE7a+5zuIQ9FI9qtY8dOOeCWDwhJLYlzFf63yHVyzHvPfxUp8iaX y3csfLZHmtABf4STGT21GD0bSug8cIqmIlhjfYgDst/LonkFEKYAk2VpdJBVVs5/DYhL Ybvg== X-Gm-Message-State: AN3rC/5c64PllrS2S5ArcgDB8/6FFMR18wyhKYNdWPBYDPX5dj1cmmZx pH4AjzEBgKvgCA== X-Received: by 10.98.2.213 with SMTP id 204mr28930963pfc.125.1493683505286; Mon, 01 May 2017 17:05:05 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id g22sm26756413pfd.22.2017.05.01.17.05.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 May 2017 17:05:04 -0700 (PDT) From: Brian Norris To: , Boris Brezillon Subject: [PATCH] mtd: nand: don't leak buffers when ->scan_bbt() fails Date: Mon, 1 May 2017 17:04:50 -0700 Message-Id: <20170502000455.13240-1-computersforpeace@gmail.com> X-Mailer: git-send-email 2.13.0.rc1.294.g07d810a77f-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170501_170526_216343_3CE0408D X-CRM114-Status: GOOD ( 10.29 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c00:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -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 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cyrille Pitchen , Richard Weinberger , Brian Norris , Ezequiel Garcia , Marek Vasut MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This bug seems to have been here forever, although we came close to fixing all of them in [1]! [1] 11eaf6df1cce ("mtd: nand: Remove BUG() abuse in nand_scan_tail") Cc: Ezequiel Garcia Signed-off-by: Brian Norris Acked-by: Ezequiel Garcia Acked-by: Boris Brezillon --- The goto isn't *really* necessary, but I thought it'd be more consistent. Compile tested only drivers/mtd/nand/nand_base.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 978242b1213f..e4919f9dece4 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -4794,7 +4794,11 @@ int nand_scan_tail(struct mtd_info *mtd) return 0; /* Build bad block table */ - return chip->scan_bbt(mtd); + ret = chip->scan_bbt(mtd); + if (ret) + goto err_free; + return 0; + err_free: if (nbuf) { kfree(nbuf->databuf);