Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp389395imu; Mon, 26 Nov 2018 23:48:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/VFhdLL3vX25v2XX3a6k+wRVKCTPfumgChUej5fZ3z4i94WPP9443S1iDRUoLF0/eiwwml1 X-Received: by 2002:a63:5c41:: with SMTP id n1mr27151207pgm.1.1543304910858; Mon, 26 Nov 2018 23:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543304910; cv=none; d=google.com; s=arc-20160816; b=q9DVlPariDssEIlWd5UQcmKiKcZKcw22AUMlyILHM/3R8kCYZPnbad8ZqBYitBVUQ5 8cpk5bnhsBAQXFRlDDfcV7vCLtufXlUr/gB505a1vySoDQOoXyb1HwQdYyWdkScnVcNF hMSLC5zTri0RVjd7QNQU1QpgzGiNEODjW4FtgGiGv7JwIMX40cLYf4o1X17uvJT9rm6K u+e9q3jjuubo43s4bNbmkSqQ7qpY83leg/gtLeqTbIx1xHrl8HcvNf6cbCSnp22sxDPs tZKlsq3KzB/cS4gkMKGPwuXXK5Ude9ffq2vw/FBw+Q9MqbQnkKqn74R2huTGlsMifXpb xd+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=oSAMXpkXBL7/FhXwqxnyTKE/EAtJBraRvo0FYwmbFeI=; b=IbDn3UxCjw7Ac65IWlNjiY8zDCM6/hsFNbXc01VctZoy+2FxcaJ3dHREicOfqvA6pM r7JaUiWL9noZjV8eHwLb/OPkjC44bBXCuuhGqs1xLBaqvf0xlzdq93lmaME+q8PlpaL6 D9vFwAQ96fto97+nOzOGo/No+GBa2pVvexgAkAm6BY2whyUt9tUyJBab/SBCpcAPMfHx B+EfAADlGJgSA7UpgOFuc2EzOna0POZeOWC/VmKSUJgQyykfyn/IASVcV6LjbCRR6dE/ hR/Ql9xBrlxxqLH6gJbMoWtX7uelfi4XRZr7SQadS6Mq1xmjAPi2eoffQT1RaFtqGEXC JFPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j22si2674687pfi.252.2018.11.26.23.48.13; Mon, 26 Nov 2018 23:48:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729187AbeK0Sl4 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 27 Nov 2018 13:41:56 -0500 Received: from skedge03.snt-world.com ([91.208.41.68]:45838 "EHLO skedge03.snt-world.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728838AbeK0Sl4 (ORCPT ); Tue, 27 Nov 2018 13:41:56 -0500 Received: from sntmail11s.snt-is.com (unknown [10.203.32.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by skedge03.snt-world.com (Postfix) with ESMTPS id 34ACA67A5AB; Tue, 27 Nov 2018 08:44:53 +0100 (CET) Received: from sntmail12r.snt-is.com (10.203.32.182) by sntmail11s.snt-is.com (10.203.32.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1466.3; Tue, 27 Nov 2018 08:44:52 +0100 Received: from sntmail12r.snt-is.com ([fe80::e551:8750:7bba:3305]) by sntmail12r.snt-is.com ([fe80::e551:8750:7bba:3305%5]) with mapi id 15.01.1466.003; Tue, 27 Nov 2018 08:44:52 +0100 From: Schrempf Frieder To: Boris Brezillon , Miquel Raynal , Richard Weinberger CC: Schrempf Frieder , "stable@vger.kernel.org" , David Woodhouse , Brian Norris , Marek Vasut , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] mtd: nand: Fix memory allocation in nanddev_bbt_init() Thread-Topic: [PATCH] mtd: nand: Fix memory allocation in nanddev_bbt_init() Thread-Index: AQHUhiUV+bbi1IymHUOKrtHQUP0AvQ== Date: Tue, 27 Nov 2018 07:44:52 +0000 Message-ID: <1543304637-27308-1-git-send-email-frieder.schrempf@kontron.de> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.25.9.43] x-c2processedorg: 51b406b7-48a2-4d03-b652-521f56ac89f3 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-SnT-MailScanner-Information: Please contact the ISP for more information X-SnT-MailScanner-ID: 34ACA67A5AB.AF014 X-SnT-MailScanner: Found to be clean X-SnT-MailScanner-SpamCheck: X-SnT-MailScanner-From: frieder.schrempf@kontron.de X-SnT-MailScanner-To: boris.brezillon@bootlin.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, marek.vasut@gmail.com, miquel.raynal@bootlin.com, richard@nod.at, stable@vger.kernel.org X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the size of the buffer allocated to store the in-memory BBT. This bug was previously hidden by a different bug, that was fixed in d098093ba06e. Fixes: 9c3736a3de21 ("mtd: nand: Add core infrastructure to deal with NAND devices") Cc: Signed-off-by: Frieder Schrempf --- drivers/mtd/nand/bbt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c index 56cde38..c12497f 100644 --- a/drivers/mtd/nand/bbt.c +++ b/drivers/mtd/nand/bbt.c @@ -27,7 +27,8 @@ int nanddev_bbt_init(struct nand_device *nand) unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block, BITS_PER_LONG); - nand->bbt.cache = kzalloc(nwords, GFP_KERNEL); + nand->bbt.cache = kzalloc(nwords * (BITS_PER_LONG / BITS_PER_BYTE), + GFP_KERNEL); if (!nand->bbt.cache) return -ENOMEM; -- 2.7.4