Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp482200imu; Tue, 27 Nov 2018 01:30:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/W3Jwo+8ReRhGrx1sRL53cOI2+WcDHpRg0nmjTbB9pNBtbIcXU1gAblxh4t1aYg5lFT1GtT X-Received: by 2002:a17:902:7402:: with SMTP id g2mr31059438pll.198.1543311040202; Tue, 27 Nov 2018 01:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543311040; cv=none; d=google.com; s=arc-20160816; b=AMO7j9t45eZ2WEKqZAaekkOttoNK/CExLpf6ULWvLPApZSwgYwuGTSPUIsZRbqFtVt brCkaqGAfMBkm5I4vjGsv8yy2KoSXw07SPdRzJZYwzu6firkiBhWNryl+9jcqkvga4lZ Msl9gfi8Oa0uah/sNvPF2Z4PcEfKFI49gQCVIa/52nxX6CpqwwsfeHrQD7aXT5NtTz39 elM4bZR0+wWH5kS/MasbfUByEENPyIfQpw5M+2ezQCFxKIQ2OneJs93EO7Z017dGnw1f NjVBzg59us0LBDKuEm4RL+TNlv4GjSmC1nP+HSc/jrABCFpF88J1Yl0mGY4zQQvemjRI ecEg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=gh9iURmMgFAKnCqnsNmJGqVwwnC+6p3aDI4TnshSJXQ=; b=IMtF5S2hBo7aRKRFotf/ljxWty7PwivsT1T5gsQR+8fGdlhQRCAzs4SbLfDIxWzvdu /odG75++nwuiUi13uzVuDqoJBw4XWTr3o5fGZ0kWMf1W1RQF6oT/uK+Uu6RAzf3AHUki WWGrFwd5Smx/ItenJIJiaQpd38iyocdQUI8Ul6+0Ygys2JfIN2r6W6xGr8lKkgbTVlMo T1h4ObdatAMQ+15cZncWWUbLyI5foYMtxKZ18lzXV+FKXM8qM0ol7v8Tye33A/miw0Us jvrvWnN7SUgzrNErX45Oz9HPsSjEYQsDqzNU1sBDph7dsk73rK94cnPI4ah96ScE/xPc RdKQ== 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 20si3475685pft.177.2018.11.27.01.30.24; Tue, 27 Nov 2018 01:30:40 -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 S1730190AbeK0UZ1 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 27 Nov 2018 15:25:27 -0500 Received: from mail.bootlin.com ([62.4.15.54]:59913 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728266AbeK0UZ0 (ORCPT ); Tue, 27 Nov 2018 15:25:26 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id CF764207AD; Tue, 27 Nov 2018 10:28:07 +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, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from xps13 (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 8721520736; Tue, 27 Nov 2018 10:27:57 +0100 (CET) Date: Tue, 27 Nov 2018 10:27:57 +0100 From: Miquel Raynal To: Schrempf Frieder Cc: Boris Brezillon , 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: <20181127102757.6adc5649@xps13> In-Reply-To: <9365718c-4993-7e3b-1519-8fef0c08c0db@kontron.de> References: <1543304637-27308-1-git-send-email-frieder.schrempf@kontron.de> <20181127092232.3a6d1661@bbrezillon> <9365718c-4993-7e3b-1519-8fef0c08c0db@kontron.de> Organization: Bootlin X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Schrempf Frieder wrote on Tue, 27 Nov 2018 08:30:24 +0000: > On 27.11.18 09:22, Boris Brezillon wrote: > > 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). > > Sure, that's ok. I also prefer with the sizeof() operator. Thanks for fixing this! Acked-by: Miquel Raynal Thanks, Miquèl