Commit 505fa2c4 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] md: fix calculation for size of filemap_attr array in md/bitmap

If 'num_pages' were ever 1 more than a multiple of 8 (32bit platforms)
or 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: default avatarNeil Brown <neilb@suse.de>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b6550777
...@@ -863,9 +863,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) ...@@ -863,9 +863,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
/* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */
bitmap->filemap_attr = kzalloc( bitmap->filemap_attr = kzalloc(
(((num_pages*4/8)+sizeof(unsigned long)-1) roundup( DIV_ROUND_UP(num_pages*4, 8), sizeof(unsigned long)),
/sizeof(unsigned long))
*sizeof(unsigned long),
GFP_KERNEL); GFP_KERNEL);
if (!bitmap->filemap_attr) if (!bitmap->filemap_attr)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment