diff options
-rw-r--r-- | drivers/md/bitmap.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index c43fd031aafe..62fac2b38000 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -781,7 +781,9 @@ static int bitmap_init_from_disk(struct bitmap *bitmap) | |||
781 | "recovery\n", bmname(bitmap)); | 781 | "recovery\n", bmname(bitmap)); |
782 | 782 | ||
783 | bytes = (chunks + 7) / 8; | 783 | bytes = (chunks + 7) / 8; |
784 | num_pages = (bytes + PAGE_SIZE - 1) / PAGE_SIZE; | 784 | |
785 | num_pages = (bytes + sizeof(bitmap_super_t) + PAGE_SIZE - 1) / PAGE_SIZE + 1; | ||
786 | |||
785 | if (i_size_read(file->f_mapping->host) < bytes + sizeof(bitmap_super_t)) { | 787 | if (i_size_read(file->f_mapping->host) < bytes + sizeof(bitmap_super_t)) { |
786 | printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n", | 788 | printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n", |
787 | bmname(bitmap), | 789 | bmname(bitmap), |
@@ -789,18 +791,16 @@ static int bitmap_init_from_disk(struct bitmap *bitmap) | |||
789 | bytes + sizeof(bitmap_super_t)); | 791 | bytes + sizeof(bitmap_super_t)); |
790 | goto out; | 792 | goto out; |
791 | } | 793 | } |
792 | num_pages++; | 794 | |
795 | ret = -ENOMEM; | ||
796 | |||
793 | bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL); | 797 | bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL); |
794 | if (!bitmap->filemap) { | 798 | if (!bitmap->filemap) |
795 | ret = -ENOMEM; | ||
796 | goto out; | 799 | goto out; |
797 | } | ||
798 | 800 | ||
799 | bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL); | 801 | bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL); |
800 | if (!bitmap->filemap_attr) { | 802 | if (!bitmap->filemap_attr) |
801 | ret = -ENOMEM; | ||
802 | goto out; | 803 | goto out; |
803 | } | ||
804 | 804 | ||
805 | memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages); | 805 | memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages); |
806 | 806 | ||