[patch 11/31] Fix calculation for size of filemap_attr array in md/bitmap.

2007-04-11 Thread Greg KH
-stable review patch.  If anyone has any objections, please let us know.

--
From: Neil Brown <[EMAIL PROTECTED]>

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 <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

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

-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 11/31] Fix calculation for size of filemap_attr array in md/bitmap.

2007-04-11 Thread Greg KH
-stable review patch.  If anyone has any objections, please let us know.

--
From: Neil Brown [EMAIL PROTECTED]

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 [EMAIL PROTECTED]
Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED]

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

-- 
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/