aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2007-04-12 02:28:44 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-12 18:31:42 -0400
commit505fa2c4a2f125a70951926dfb22b9cf273994f1 (patch)
treeaa96fd86c3a26bcd062c1e19e527faf684848516 /drivers/md/bitmap.c
parentb6550777a32f7204f87475beb4f40d054fb8d4b4 (diff)
[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: Neil Brown <neilb@suse.de> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 5554adaa58f9..e61e0efe9ec7 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -863,9 +863,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
863 863
864 /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ 864 /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */
865 bitmap->filemap_attr = kzalloc( 865 bitmap->filemap_attr = kzalloc(
866 (((num_pages*4/8)+sizeof(unsigned long)-1) 866 roundup( DIV_ROUND_UP(num_pages*4, 8), sizeof(unsigned long)),
867 /sizeof(unsigned long))
868 *sizeof(unsigned long),
869 GFP_KERNEL); 867 GFP_KERNEL);
870 if (!bitmap->filemap_attr) 868 if (!bitmap->filemap_attr)
871 goto out; 869 goto out;