Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp421815imu; Tue, 27 Nov 2018 00:26:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/VlKO1C7EOpIqbHEQxXnW6bLKWLeqSqg34DF026PQ8nF0pQM9kl418+b9En419oxtTqNuKU X-Received: by 2002:a63:fa02:: with SMTP id y2mr28716036pgh.177.1543307184419; Tue, 27 Nov 2018 00:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543307184; cv=none; d=google.com; s=arc-20160816; b=QdWYOZzl9M9OcF4/CYcccfXkP7Ky1fOyV/IO3banQRFahQglkbHYftV9rrAAbvpvRB jOroKgSYdnK8e+/aTlQ+4mdUjWS8Bx4+EDXcpKfrLNrTxO9y7M8DNYp/2rLFCdOhGo9m Wk1Lyl7X8gWx6IRjpi3ukMyEa22EV1vcEU8VAAf6Vr36kMLC8lawVjtJWkiqsmG9Ip8A hyAn6obOk3QZ45QdIiha+PqRaeq//Yiu2DaqmYZUQQct9R6Izx7y48KJ1zDysLMytnVy 2ta+wh6jhJIdCMsMReKIQDmzvP8bVPDZtwqNdSqXd3RFxAui6p59IdVgmDJXmtfdrCig wIJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=MGJrMC0U6dO6K2ORQDKyl4R0qhK2EhNOcDve0zvHWcw=; b=B66pUAvATPN2zZOryexuTmzUfxDslIysCZt5SBrxx05RQ//qUquW3Ke+EYeP7ww4Mw btwaIipsX6o4vfE9afSLsVGqui3UNtWvUn26aMBchAR1tFPYgck2OWev5LirEftP88D9 5LCMooG5X9M/HrB6laFqGaNj6D5Zm2+JKtEP5nxIbep6Ds1zWpskesIQ/1WwkVw1zugB clPAhtMC5jKK/Nf+Eu2BKxvzG/nGlGKcShsOyNt2BgTC+4AQqfn488FQoDaaedBBMjGG qKTDLRH9VSjuTO3w2FMjBYrgWdMpvi9tTZea3bhEceVCx9Dw1+w99cJK2GmUGnC1BZ17 dubw== 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 o3si3243587pgi.388.2018.11.27.00.26.09; Tue, 27 Nov 2018 00:26:24 -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 S1729399AbeK0TTw (ORCPT + 99 others); Tue, 27 Nov 2018 14:19:52 -0500 Received: from mail.bootlin.com ([62.4.15.54]:55217 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727745AbeK0TTv (ORCPT ); Tue, 27 Nov 2018 14:19:51 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id CB8DA20D29; Tue, 27 Nov 2018 09:22:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 80F6C20745; Tue, 27 Nov 2018 09:22:34 +0100 (CET) Date: Tue, 27 Nov 2018 09:22:32 +0100 From: Boris Brezillon To: Schrempf Frieder Cc: Miquel Raynal , Richard Weinberger , "stable@vger.kernel.org" , David Woodhouse , Brian Norris , Marek Vasut , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mtd: nand: Fix memory allocation in nanddev_bbt_init() Message-ID: <20181127092232.3a6d1661@bbrezillon> In-Reply-To: <1543304637-27308-1-git-send-email-frieder.schrempf@kontron.de> References: <1543304637-27308-1-git-send-email-frieder.schrempf@kontron.de> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Nov 2018 07:44:52 +0000 Schrempf Frieder wrote: > 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. Oops :-/. > > 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), I prefer * sizeof(*nand->bbt.cache) If you're okay with this change, I'll fix it when applying (no need to send a new version). Thanks, Boris > + GFP_KERNEL); > if (!nand->bbt.cache) > return -ENOMEM; >