mtdoops: fix the oops_page_used array size

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Jan 9 13:59:07 EST 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=556f063580db2953a7e53cd46b47724246320f60
Commit:     556f063580db2953a7e53cd46b47724246320f60
Parent:     53466710202900ce49e471f480cac11275e1d0c4
Author:     Roman Tereshonkov <roman.tereshonkov at nokia.com>
AuthorDate: Tue Nov 29 12:49:18 2011 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Jan 9 18:18:11 2012 +0000

    mtdoops: fix the oops_page_used array size
    
    The array of unsigned long pointed by oops_page_used is allocated
    by vmalloc which requires the size to be in bytes.
    
    BITS_PER_LONG is equal to 32.
    If we want to allocate memory for 32 pages with one bit per page then
    32 / BITS_PER_LONG  is equal to 1 byte that is 8 bits.
    To fix it we need to multiply the result by sizeof(unsigned long) equal to 4.
    
    Cc: stable at kernel.org
    Signed-off-by: Roman Tereshonkov <roman.tereshonkov at nokia.com>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtdoops.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index cea9279..f3cdce9 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -372,7 +372,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
 
 	/* oops_page_used is a bit field */
 	cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
-			BITS_PER_LONG));
+			BITS_PER_LONG) * sizeof(unsigned long));
 	if (!cxt->oops_page_used) {
 		printk(KERN_ERR "mtdoops: could not allocate page array\n");
 		return;



More information about the linux-mtd-cvs mailing list