[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>

authored by Neil Brown and committed by Linus Torvalds 505fa2c4 b6550777

+1 -3
+1 -3
drivers/md/bitmap.c
··· 863 864 /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ 865 bitmap->filemap_attr = kzalloc( 866 - (((num_pages*4/8)+sizeof(unsigned long)-1) 867 - /sizeof(unsigned long)) 868 - *sizeof(unsigned long), 869 GFP_KERNEL); 870 if (!bitmap->filemap_attr) 871 goto out;
··· 863 864 /* We need 4 bits per page, rounded up to a multiple of sizeof(unsigned long) */ 865 bitmap->filemap_attr = kzalloc( 866 + roundup( DIV_ROUND_UP(num_pages*4, 8), sizeof(unsigned long)), 867 GFP_KERNEL); 868 if (!bitmap->filemap_attr) 869 goto out;