From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161404AbXDKXFi (ORCPT ); Wed, 11 Apr 2007 19:05:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1161347AbXDKXFf (ORCPT ); Wed, 11 Apr 2007 19:05:35 -0400 Received: from canuck.infradead.org ([209.217.80.40]:55576 "EHLO canuck.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161351AbXDKWyb (ORCPT ); Wed, 11 Apr 2007 18:54:31 -0400 Date: Wed, 11 Apr 2007 15:51:52 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org, Reuben Farrelly Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, linux-raid@vger.kernel.org, Neil Brown Subject: [patch 11/31] Fix calculation for size of filemap_attr array in md/bitmap. Message-ID: <20070411225152.GL24814@kroah.com> References: <20070411224329.866978349@mini.kroah.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="fix-calculation-for-size-of-filemap_attr-array-in-md-bitmap.patch" In-Reply-To: <20070411225100.GA24814@kroah.com> User-Agent: Mutt/1.5.14 (2007-02-12) X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org -stable review patch. If anyone has any objections, please let us know. ------------------ From: Neil Brown If 'num_pages' were ever 1 more than a multiple of 8 (32bit platforms) for of 16 (64 bit platforms). filemap_attr would be allocated one 'unsigned long' shorter than required. We need a round-up in there. Signed-off-by: Neil Brown Signed-off-by: Greg Kroah-Hartman --- drivers/md/bitmap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -863,9 +863,7 @@ static int bitmap_init_from_disk(struct /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ bitmap->filemap_attr = kzalloc( - (((num_pages*4/8)+sizeof(unsigned long)-1) - /sizeof(unsigned long)) - *sizeof(unsigned long), + roundup( DIV_ROUND_UP(num_pages*4, 8), sizeof(unsigned long)), GFP_KERNEL); if (!bitmap->filemap_attr) goto out; --