aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/mtdoops.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index 06c538249455..b016eee18657 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -33,6 +33,9 @@
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/mtd/mtd.h> 34#include <linux/mtd/mtd.h>
35 35
36/* Maximum MTD partition size */
37#define MTDOOPS_MAX_MTD_SIZE (8 * 1024 * 1024)
38
36#define MTDOOPS_KERNMSG_MAGIC 0x5d005d00 39#define MTDOOPS_KERNMSG_MAGIC 0x5d005d00
37#define OOPS_PAGE_SIZE 4096 40#define OOPS_PAGE_SIZE 4096
38 41
@@ -310,6 +313,12 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
310 return; 313 return;
311 } 314 }
312 315
316 if (mtd->size > MTDOOPS_MAX_MTD_SIZE) {
317 printk(KERN_ERR "mtdoops: mtd%d is too large (limit is %d MiB)\n",
318 mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024);
319 return;
320 }
321
313 /* oops_page_used is a bit field */ 322 /* oops_page_used is a bit field */
314 cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages, 323 cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
315 BITS_PER_LONG)); 324 BITS_PER_LONG));
@@ -317,14 +326,10 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
317 printk(KERN_ERR "Could not allocate page array\n"); 326 printk(KERN_ERR "Could not allocate page array\n");
318 return; 327 return;
319 } 328 }
320 cxt->mtd = mtd;
321 if (mtd->size > INT_MAX)
322 cxt->oops_pages = INT_MAX / OOPS_PAGE_SIZE;
323 else
324 cxt->oops_pages = (int)mtd->size / OOPS_PAGE_SIZE;
325 329
330 cxt->mtd = mtd;
331 cxt->oops_pages = (int)mtd->size / OOPS_PAGE_SIZE;
326 find_next_position(cxt); 332 find_next_position(cxt);
327
328 printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index); 333 printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index);
329} 334}
330 335