diff options
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 9 | ||||
-rw-r--r-- | drivers/mtd/devices/doc2000.c | 8 | ||||
-rw-r--r-- | drivers/mtd/devices/doc2001.c | 8 | ||||
-rw-r--r-- | drivers/mtd/devices/doc2001plus.c | 8 | ||||
-rw-r--r-- | drivers/mtd/devices/lart.c | 5 | ||||
-rw-r--r-- | drivers/mtd/devices/m25p80.c | 12 | ||||
-rw-r--r-- | drivers/mtd/devices/ms02-nv.c | 8 | ||||
-rw-r--r-- | drivers/mtd/devices/mtd_dataflash.c | 7 | ||||
-rw-r--r-- | drivers/mtd/devices/mtdram.c | 17 | ||||
-rw-r--r-- | drivers/mtd/devices/phram.c | 23 | ||||
-rw-r--r-- | drivers/mtd/devices/pmc551.c | 38 | ||||
-rw-r--r-- | drivers/mtd/devices/slram.c | 23 | ||||
-rw-r--r-- | drivers/mtd/devices/spear_smi.c | 12 | ||||
-rw-r--r-- | drivers/mtd/devices/sst25l.c | 9 |
14 files changed, 0 insertions, 187 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 0fccf149f5aa..4c2f84c2a7c7 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -104,11 +104,6 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
104 | int offset = from & (PAGE_SIZE-1); | 104 | int offset = from & (PAGE_SIZE-1); |
105 | int cpylen; | 105 | int cpylen; |
106 | 106 | ||
107 | if (from > mtd->size) | ||
108 | return -EINVAL; | ||
109 | if (from + len > mtd->size) | ||
110 | len = mtd->size - from; | ||
111 | |||
112 | if (retlen) | 107 | if (retlen) |
113 | *retlen = 0; | 108 | *retlen = 0; |
114 | 109 | ||
@@ -190,10 +185,6 @@ static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
190 | 185 | ||
191 | if (!len) | 186 | if (!len) |
192 | return 0; | 187 | return 0; |
193 | if (to >= mtd->size) | ||
194 | return -ENOSPC; | ||
195 | if (to + len > mtd->size) | ||
196 | len = mtd->size - to; | ||
197 | 188 | ||
198 | mutex_lock(&dev->write_mutex); | 189 | mutex_lock(&dev->write_mutex); |
199 | err = _block2mtd_write(dev, buf, to, len, retlen); | 190 | err = _block2mtd_write(dev, buf, to, len, retlen); |
diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c index 115d890e9919..ee4ee0b8440d 100644 --- a/drivers/mtd/devices/doc2000.c +++ b/drivers/mtd/devices/doc2000.c | |||
@@ -602,10 +602,6 @@ static int doc_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
602 | int i, len256 = 0, ret=0; | 602 | int i, len256 = 0, ret=0; |
603 | size_t left = len; | 603 | size_t left = len; |
604 | 604 | ||
605 | /* Don't allow read past end of device */ | ||
606 | if (from >= this->totlen) | ||
607 | return -EINVAL; | ||
608 | |||
609 | mutex_lock(&this->lock); | 605 | mutex_lock(&this->lock); |
610 | 606 | ||
611 | *retlen = 0; | 607 | *retlen = 0; |
@@ -748,10 +744,6 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
748 | size_t left = len; | 744 | size_t left = len; |
749 | int status; | 745 | int status; |
750 | 746 | ||
751 | /* Don't allow write past end of device */ | ||
752 | if (to >= this->totlen) | ||
753 | return -EINVAL; | ||
754 | |||
755 | mutex_lock(&this->lock); | 747 | mutex_lock(&this->lock); |
756 | 748 | ||
757 | *retlen = 0; | 749 | *retlen = 0; |
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c index b1185f938711..17844155a685 100644 --- a/drivers/mtd/devices/doc2001.c +++ b/drivers/mtd/devices/doc2001.c | |||
@@ -383,10 +383,6 @@ static int doc_read (struct mtd_info *mtd, loff_t from, size_t len, | |||
383 | void __iomem *docptr = this->virtadr; | 383 | void __iomem *docptr = this->virtadr; |
384 | struct Nand *mychip = &this->chips[from >> (this->chipshift)]; | 384 | struct Nand *mychip = &this->chips[from >> (this->chipshift)]; |
385 | 385 | ||
386 | /* Don't allow read past end of device */ | ||
387 | if (from >= this->totlen) | ||
388 | return -EINVAL; | ||
389 | |||
390 | /* Don't allow a single read to cross a 512-byte block boundary */ | 386 | /* Don't allow a single read to cross a 512-byte block boundary */ |
391 | if (from + len > ((from | 0x1ff) + 1)) | 387 | if (from + len > ((from | 0x1ff) + 1)) |
392 | len = ((from | 0x1ff) + 1) - from; | 388 | len = ((from | 0x1ff) + 1) - from; |
@@ -494,10 +490,6 @@ static int doc_write (struct mtd_info *mtd, loff_t to, size_t len, | |||
494 | void __iomem *docptr = this->virtadr; | 490 | void __iomem *docptr = this->virtadr; |
495 | struct Nand *mychip = &this->chips[to >> (this->chipshift)]; | 491 | struct Nand *mychip = &this->chips[to >> (this->chipshift)]; |
496 | 492 | ||
497 | /* Don't allow write past end of device */ | ||
498 | if (to >= this->totlen) | ||
499 | return -EINVAL; | ||
500 | |||
501 | #if 0 | 493 | #if 0 |
502 | /* Don't allow a single write to cross a 512-byte block boundary */ | 494 | /* Don't allow a single write to cross a 512-byte block boundary */ |
503 | if (to + len > ( (to | 0x1ff) + 1)) | 495 | if (to + len > ( (to | 0x1ff) + 1)) |
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c index c9fbadd3303e..a472bab7ef2b 100644 --- a/drivers/mtd/devices/doc2001plus.c +++ b/drivers/mtd/devices/doc2001plus.c | |||
@@ -581,10 +581,6 @@ static int doc_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
581 | void __iomem * docptr = this->virtadr; | 581 | void __iomem * docptr = this->virtadr; |
582 | struct Nand *mychip = &this->chips[from >> (this->chipshift)]; | 582 | struct Nand *mychip = &this->chips[from >> (this->chipshift)]; |
583 | 583 | ||
584 | /* Don't allow read past end of device */ | ||
585 | if (from >= this->totlen) | ||
586 | return -EINVAL; | ||
587 | |||
588 | /* Don't allow a single read to cross a 512-byte block boundary */ | 584 | /* Don't allow a single read to cross a 512-byte block boundary */ |
589 | if (from + len > ((from | 0x1ff) + 1)) | 585 | if (from + len > ((from | 0x1ff) + 1)) |
590 | len = ((from | 0x1ff) + 1) - from; | 586 | len = ((from | 0x1ff) + 1) - from; |
@@ -700,10 +696,6 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
700 | void __iomem * docptr = this->virtadr; | 696 | void __iomem * docptr = this->virtadr; |
701 | struct Nand *mychip = &this->chips[to >> (this->chipshift)]; | 697 | struct Nand *mychip = &this->chips[to >> (this->chipshift)]; |
702 | 698 | ||
703 | /* Don't allow write past end of device */ | ||
704 | if (to >= this->totlen) | ||
705 | return -EINVAL; | ||
706 | |||
707 | /* Don't allow writes which aren't exactly one block (512 bytes) */ | 699 | /* Don't allow writes which aren't exactly one block (512 bytes) */ |
708 | if ((to & 0x1ff) || (len != 0x200)) | 700 | if ((to & 0x1ff) || (len != 0x200)) |
709 | return -EINVAL; | 701 | return -EINVAL; |
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c index 6d6502c2ec35..c9ae60112a90 100644 --- a/drivers/mtd/devices/lart.c +++ b/drivers/mtd/devices/lart.c | |||
@@ -367,9 +367,6 @@ static int flash_erase (struct mtd_info *mtd,struct erase_info *instr) | |||
367 | printk (KERN_DEBUG "%s(addr = 0x%.8x, len = %d)\n", __func__, instr->addr, instr->len); | 367 | printk (KERN_DEBUG "%s(addr = 0x%.8x, len = %d)\n", __func__, instr->addr, instr->len); |
368 | #endif | 368 | #endif |
369 | 369 | ||
370 | /* sanity checks */ | ||
371 | if (instr->addr + instr->len > mtd->size) return (-EINVAL); | ||
372 | |||
373 | /* | 370 | /* |
374 | * check that both start and end of the requested erase are | 371 | * check that both start and end of the requested erase are |
375 | * aligned with the erasesize at the appropriate addresses. | 372 | * aligned with the erasesize at the appropriate addresses. |
@@ -442,7 +439,6 @@ static int flash_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retle | |||
442 | 439 | ||
443 | /* sanity checks */ | 440 | /* sanity checks */ |
444 | if (!len) return (0); | 441 | if (!len) return (0); |
445 | if (from + len > mtd->size) return (-EINVAL); | ||
446 | 442 | ||
447 | /* we always read len bytes */ | 443 | /* we always read len bytes */ |
448 | *retlen = len; | 444 | *retlen = len; |
@@ -526,7 +522,6 @@ static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen | |||
526 | 522 | ||
527 | /* sanity checks */ | 523 | /* sanity checks */ |
528 | if (!len) return (0); | 524 | if (!len) return (0); |
529 | if (to + len > mtd->size) return (-EINVAL); | ||
530 | 525 | ||
531 | /* first, we write a 0xFF.... padded byte until we reach a dword boundary */ | 526 | /* first, we write a 0xFF.... padded byte until we reach a dword boundary */ |
532 | if (to & (BUSWIDTH - 1)) | 527 | if (to & (BUSWIDTH - 1)) |
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 8808da9ee31f..0955a8f4fd25 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
@@ -288,9 +288,6 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
288 | __func__, (long long)instr->addr, | 288 | __func__, (long long)instr->addr, |
289 | (long long)instr->len); | 289 | (long long)instr->len); |
290 | 290 | ||
291 | /* sanity checks */ | ||
292 | if (instr->addr + instr->len > flash->mtd.size) | ||
293 | return -EINVAL; | ||
294 | div_u64_rem(instr->len, mtd->erasesize, &rem); | 291 | div_u64_rem(instr->len, mtd->erasesize, &rem); |
295 | if (rem) | 292 | if (rem) |
296 | return -EINVAL; | 293 | return -EINVAL; |
@@ -353,9 +350,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
353 | if (!len) | 350 | if (!len) |
354 | return 0; | 351 | return 0; |
355 | 352 | ||
356 | if (from + len > flash->mtd.size) | ||
357 | return -EINVAL; | ||
358 | |||
359 | spi_message_init(&m); | 353 | spi_message_init(&m); |
360 | memset(t, 0, (sizeof t)); | 354 | memset(t, 0, (sizeof t)); |
361 | 355 | ||
@@ -423,9 +417,6 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
423 | if (!len) | 417 | if (!len) |
424 | return(0); | 418 | return(0); |
425 | 419 | ||
426 | if (to + len > flash->mtd.size) | ||
427 | return -EINVAL; | ||
428 | |||
429 | spi_message_init(&m); | 420 | spi_message_init(&m); |
430 | memset(t, 0, (sizeof t)); | 421 | memset(t, 0, (sizeof t)); |
431 | 422 | ||
@@ -515,9 +506,6 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
515 | if (!len) | 506 | if (!len) |
516 | return 0; | 507 | return 0; |
517 | 508 | ||
518 | if (to + len > flash->mtd.size) | ||
519 | return -EINVAL; | ||
520 | |||
521 | spi_message_init(&m); | 509 | spi_message_init(&m); |
522 | memset(t, 0, (sizeof t)); | 510 | memset(t, 0, (sizeof t)); |
523 | 511 | ||
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c index 3a05af529e7d..182849d39c61 100644 --- a/drivers/mtd/devices/ms02-nv.c +++ b/drivers/mtd/devices/ms02-nv.c | |||
@@ -59,12 +59,8 @@ static int ms02nv_read(struct mtd_info *mtd, loff_t from, | |||
59 | { | 59 | { |
60 | struct ms02nv_private *mp = mtd->priv; | 60 | struct ms02nv_private *mp = mtd->priv; |
61 | 61 | ||
62 | if (from + len > mtd->size) | ||
63 | return -EINVAL; | ||
64 | |||
65 | memcpy(buf, mp->uaddr + from, len); | 62 | memcpy(buf, mp->uaddr + from, len); |
66 | *retlen = len; | 63 | *retlen = len; |
67 | |||
68 | return 0; | 64 | return 0; |
69 | } | 65 | } |
70 | 66 | ||
@@ -73,12 +69,8 @@ static int ms02nv_write(struct mtd_info *mtd, loff_t to, | |||
73 | { | 69 | { |
74 | struct ms02nv_private *mp = mtd->priv; | 70 | struct ms02nv_private *mp = mtd->priv; |
75 | 71 | ||
76 | if (to + len > mtd->size) | ||
77 | return -EINVAL; | ||
78 | |||
79 | memcpy(mp->uaddr + to, buf, len); | 72 | memcpy(mp->uaddr + to, buf, len); |
80 | *retlen = len; | 73 | *retlen = len; |
81 | |||
82 | return 0; | 74 | return 0; |
83 | } | 75 | } |
84 | 76 | ||
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index fd4a9fc0d8b8..fc5c78171844 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c | |||
@@ -164,9 +164,6 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
164 | dev_name(&spi->dev), (long long)instr->addr, | 164 | dev_name(&spi->dev), (long long)instr->addr, |
165 | (long long)instr->len); | 165 | (long long)instr->len); |
166 | 166 | ||
167 | /* Sanity checks */ | ||
168 | if (instr->addr + instr->len > mtd->size) | ||
169 | return -EINVAL; | ||
170 | div_u64_rem(instr->len, priv->page_size, &rem); | 167 | div_u64_rem(instr->len, priv->page_size, &rem); |
171 | if (rem) | 168 | if (rem) |
172 | return -EINVAL; | 169 | return -EINVAL; |
@@ -257,8 +254,6 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
257 | /* Sanity checks */ | 254 | /* Sanity checks */ |
258 | if (!len) | 255 | if (!len) |
259 | return 0; | 256 | return 0; |
260 | if (from + len > mtd->size) | ||
261 | return -EINVAL; | ||
262 | 257 | ||
263 | /* Calculate flash page/byte address */ | 258 | /* Calculate flash page/byte address */ |
264 | addr = (((unsigned)from / priv->page_size) << priv->page_offset) | 259 | addr = (((unsigned)from / priv->page_size) << priv->page_offset) |
@@ -333,8 +328,6 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
333 | /* Sanity checks */ | 328 | /* Sanity checks */ |
334 | if (!len) | 329 | if (!len) |
335 | return 0; | 330 | return 0; |
336 | if ((to + len) > mtd->size) | ||
337 | return -EINVAL; | ||
338 | 331 | ||
339 | spi_message_init(&msg); | 332 | spi_message_init(&msg); |
340 | 333 | ||
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index e1f017bf0777..0e0e6ed4443c 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c | |||
@@ -34,27 +34,18 @@ static struct mtd_info *mtd_info; | |||
34 | 34 | ||
35 | static int ram_erase(struct mtd_info *mtd, struct erase_info *instr) | 35 | static int ram_erase(struct mtd_info *mtd, struct erase_info *instr) |
36 | { | 36 | { |
37 | if (instr->addr + instr->len > mtd->size) | ||
38 | return -EINVAL; | ||
39 | |||
40 | memset((char *)mtd->priv + instr->addr, 0xff, instr->len); | 37 | memset((char *)mtd->priv + instr->addr, 0xff, instr->len); |
41 | |||
42 | instr->state = MTD_ERASE_DONE; | 38 | instr->state = MTD_ERASE_DONE; |
43 | mtd_erase_callback(instr); | 39 | mtd_erase_callback(instr); |
44 | |||
45 | return 0; | 40 | return 0; |
46 | } | 41 | } |
47 | 42 | ||
48 | static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, | 43 | static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, |
49 | size_t *retlen, void **virt, resource_size_t *phys) | 44 | size_t *retlen, void **virt, resource_size_t *phys) |
50 | { | 45 | { |
51 | if (from + len > mtd->size) | ||
52 | return -EINVAL; | ||
53 | |||
54 | /* can we return a physical address with this driver? */ | 46 | /* can we return a physical address with this driver? */ |
55 | if (phys) | 47 | if (phys) |
56 | return -EINVAL; | 48 | return -EINVAL; |
57 | |||
58 | *virt = mtd->priv + from; | 49 | *virt = mtd->priv + from; |
59 | *retlen = len; | 50 | *retlen = len; |
60 | return 0; | 51 | return 0; |
@@ -81,11 +72,7 @@ static unsigned long ram_get_unmapped_area(struct mtd_info *mtd, | |||
81 | static int ram_read(struct mtd_info *mtd, loff_t from, size_t len, | 72 | static int ram_read(struct mtd_info *mtd, loff_t from, size_t len, |
82 | size_t *retlen, u_char *buf) | 73 | size_t *retlen, u_char *buf) |
83 | { | 74 | { |
84 | if (from + len > mtd->size) | ||
85 | return -EINVAL; | ||
86 | |||
87 | memcpy(buf, mtd->priv + from, len); | 75 | memcpy(buf, mtd->priv + from, len); |
88 | |||
89 | *retlen = len; | 76 | *retlen = len; |
90 | return 0; | 77 | return 0; |
91 | } | 78 | } |
@@ -93,11 +80,7 @@ static int ram_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
93 | static int ram_write(struct mtd_info *mtd, loff_t to, size_t len, | 80 | static int ram_write(struct mtd_info *mtd, loff_t to, size_t len, |
94 | size_t *retlen, const u_char *buf) | 81 | size_t *retlen, const u_char *buf) |
95 | { | 82 | { |
96 | if (to + len > mtd->size) | ||
97 | return -EINVAL; | ||
98 | |||
99 | memcpy((char *)mtd->priv + to, buf, len); | 83 | memcpy((char *)mtd->priv + to, buf, len); |
100 | |||
101 | *retlen = len; | 84 | *retlen = len; |
102 | return 0; | 85 | return 0; |
103 | } | 86 | } |
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 38035551a7d2..36add7ce4632 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
@@ -38,29 +38,20 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
38 | { | 38 | { |
39 | u_char *start = mtd->priv; | 39 | u_char *start = mtd->priv; |
40 | 40 | ||
41 | if (instr->addr + instr->len > mtd->size) | ||
42 | return -EINVAL; | ||
43 | |||
44 | memset(start + instr->addr, 0xff, instr->len); | 41 | memset(start + instr->addr, 0xff, instr->len); |
45 | 42 | ||
46 | /* This'll catch a few races. Free the thing before returning :) | 43 | /* This'll catch a few races. Free the thing before returning :) |
47 | * I don't feel at all ashamed. This kind of thing is possible anyway | 44 | * I don't feel at all ashamed. This kind of thing is possible anyway |
48 | * with flash, but unlikely. | 45 | * with flash, but unlikely. |
49 | */ | 46 | */ |
50 | |||
51 | instr->state = MTD_ERASE_DONE; | 47 | instr->state = MTD_ERASE_DONE; |
52 | |||
53 | mtd_erase_callback(instr); | 48 | mtd_erase_callback(instr); |
54 | |||
55 | return 0; | 49 | return 0; |
56 | } | 50 | } |
57 | 51 | ||
58 | static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, | 52 | static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, |
59 | size_t *retlen, void **virt, resource_size_t *phys) | 53 | size_t *retlen, void **virt, resource_size_t *phys) |
60 | { | 54 | { |
61 | if (from + len > mtd->size) | ||
62 | return -EINVAL; | ||
63 | |||
64 | /* can we return a physical address with this driver? */ | 55 | /* can we return a physical address with this driver? */ |
65 | if (phys) | 56 | if (phys) |
66 | return -EINVAL; | 57 | return -EINVAL; |
@@ -80,14 +71,7 @@ static int phram_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
80 | { | 71 | { |
81 | u_char *start = mtd->priv; | 72 | u_char *start = mtd->priv; |
82 | 73 | ||
83 | if (from >= mtd->size) | ||
84 | return -EINVAL; | ||
85 | |||
86 | if (len > mtd->size - from) | ||
87 | len = mtd->size - from; | ||
88 | |||
89 | memcpy(buf, start + from, len); | 74 | memcpy(buf, start + from, len); |
90 | |||
91 | *retlen = len; | 75 | *retlen = len; |
92 | return 0; | 76 | return 0; |
93 | } | 77 | } |
@@ -97,14 +81,7 @@ static int phram_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
97 | { | 81 | { |
98 | u_char *start = mtd->priv; | 82 | u_char *start = mtd->priv; |
99 | 83 | ||
100 | if (to >= mtd->size) | ||
101 | return -EINVAL; | ||
102 | |||
103 | if (len > mtd->size - to) | ||
104 | len = mtd->size - to; | ||
105 | |||
106 | memcpy(start + to, buf, len); | 84 | memcpy(start + to, buf, len); |
107 | |||
108 | *retlen = len; | 85 | *retlen = len; |
109 | return 0; | 86 | return 0; |
110 | } | 87 | } |
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index 933127ecebe5..d394e06e4279 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c | |||
@@ -116,16 +116,6 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
116 | #endif | 116 | #endif |
117 | 117 | ||
118 | end = instr->addr + instr->len - 1; | 118 | end = instr->addr + instr->len - 1; |
119 | |||
120 | /* Is it past the end? */ | ||
121 | if (end > mtd->size) { | ||
122 | #ifdef CONFIG_MTD_PMC551_DEBUG | ||
123 | printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n", | ||
124 | (long)end, (long)mtd->size); | ||
125 | #endif | ||
126 | return -EINVAL; | ||
127 | } | ||
128 | |||
129 | eoff_hi = end & ~(priv->asize - 1); | 119 | eoff_hi = end & ~(priv->asize - 1); |
130 | soff_hi = instr->addr & ~(priv->asize - 1); | 120 | soff_hi = instr->addr & ~(priv->asize - 1); |
131 | eoff_lo = end & (priv->asize - 1); | 121 | eoff_lo = end & (priv->asize - 1); |
@@ -179,14 +169,6 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
179 | printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len); | 169 | printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len); |
180 | #endif | 170 | #endif |
181 | 171 | ||
182 | if (from + len > mtd->size) { | ||
183 | #ifdef CONFIG_MTD_PMC551_DEBUG | ||
184 | printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n", | ||
185 | (long)from + len, (long)mtd->size); | ||
186 | #endif | ||
187 | return -EINVAL; | ||
188 | } | ||
189 | |||
190 | /* can we return a physical address with this driver? */ | 172 | /* can we return a physical address with this driver? */ |
191 | if (phys) | 173 | if (phys) |
192 | return -EINVAL; | 174 | return -EINVAL; |
@@ -230,16 +212,6 @@ static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
230 | #endif | 212 | #endif |
231 | 213 | ||
232 | end = from + len - 1; | 214 | end = from + len - 1; |
233 | |||
234 | /* Is it past the end? */ | ||
235 | if (end > mtd->size) { | ||
236 | #ifdef CONFIG_MTD_PMC551_DEBUG | ||
237 | printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n", | ||
238 | (long)end, (long)mtd->size); | ||
239 | #endif | ||
240 | return -EINVAL; | ||
241 | } | ||
242 | |||
243 | soff_hi = from & ~(priv->asize - 1); | 215 | soff_hi = from & ~(priv->asize - 1); |
244 | eoff_hi = end & ~(priv->asize - 1); | 216 | eoff_hi = end & ~(priv->asize - 1); |
245 | soff_lo = from & (priv->asize - 1); | 217 | soff_lo = from & (priv->asize - 1); |
@@ -297,16 +269,6 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
297 | #endif | 269 | #endif |
298 | 270 | ||
299 | end = to + len - 1; | 271 | end = to + len - 1; |
300 | /* Is it past the end? or did the u32 wrap? */ | ||
301 | if (end > mtd->size) { | ||
302 | #ifdef CONFIG_MTD_PMC551_DEBUG | ||
303 | printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, " | ||
304 | "size: %ld, to: %ld)\n", (long)end, (long)mtd->size, | ||
305 | (long)to); | ||
306 | #endif | ||
307 | return -EINVAL; | ||
308 | } | ||
309 | |||
310 | soff_hi = to & ~(priv->asize - 1); | 272 | soff_hi = to & ~(priv->asize - 1); |
311 | eoff_hi = end & ~(priv->asize - 1); | 273 | eoff_hi = end & ~(priv->asize - 1); |
312 | soff_lo = to & (priv->asize - 1); | 274 | soff_lo = to & (priv->asize - 1); |
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index 9431ffc761c2..842e4890d771 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c | |||
@@ -84,21 +84,13 @@ static int slram_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
84 | { | 84 | { |
85 | slram_priv_t *priv = mtd->priv; | 85 | slram_priv_t *priv = mtd->priv; |
86 | 86 | ||
87 | if (instr->addr + instr->len > mtd->size) { | ||
88 | return(-EINVAL); | ||
89 | } | ||
90 | |||
91 | memset(priv->start + instr->addr, 0xff, instr->len); | 87 | memset(priv->start + instr->addr, 0xff, instr->len); |
92 | |||
93 | /* This'll catch a few races. Free the thing before returning :) | 88 | /* This'll catch a few races. Free the thing before returning :) |
94 | * I don't feel at all ashamed. This kind of thing is possible anyway | 89 | * I don't feel at all ashamed. This kind of thing is possible anyway |
95 | * with flash, but unlikely. | 90 | * with flash, but unlikely. |
96 | */ | 91 | */ |
97 | |||
98 | instr->state = MTD_ERASE_DONE; | 92 | instr->state = MTD_ERASE_DONE; |
99 | |||
100 | mtd_erase_callback(instr); | 93 | mtd_erase_callback(instr); |
101 | |||
102 | return(0); | 94 | return(0); |
103 | } | 95 | } |
104 | 96 | ||
@@ -110,10 +102,6 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
110 | /* can we return a physical address with this driver? */ | 102 | /* can we return a physical address with this driver? */ |
111 | if (phys) | 103 | if (phys) |
112 | return -EINVAL; | 104 | return -EINVAL; |
113 | |||
114 | if (from + len > mtd->size) | ||
115 | return -EINVAL; | ||
116 | |||
117 | *virt = priv->start + from; | 105 | *virt = priv->start + from; |
118 | *retlen = len; | 106 | *retlen = len; |
119 | return(0); | 107 | return(0); |
@@ -129,14 +117,7 @@ static int slram_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
129 | { | 117 | { |
130 | slram_priv_t *priv = mtd->priv; | 118 | slram_priv_t *priv = mtd->priv; |
131 | 119 | ||
132 | if (from > mtd->size) | ||
133 | return -EINVAL; | ||
134 | |||
135 | if (from + len > mtd->size) | ||
136 | len = mtd->size - from; | ||
137 | |||
138 | memcpy(buf, priv->start + from, len); | 120 | memcpy(buf, priv->start + from, len); |
139 | |||
140 | *retlen = len; | 121 | *retlen = len; |
141 | return(0); | 122 | return(0); |
142 | } | 123 | } |
@@ -146,11 +127,7 @@ static int slram_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
146 | { | 127 | { |
147 | slram_priv_t *priv = mtd->priv; | 128 | slram_priv_t *priv = mtd->priv; |
148 | 129 | ||
149 | if (to + len > mtd->size) | ||
150 | return -EINVAL; | ||
151 | |||
152 | memcpy(priv->start + to, buf, len); | 130 | memcpy(priv->start + to, buf, len); |
153 | |||
154 | *retlen = len; | 131 | *retlen = len; |
155 | return(0); | 132 | return(0); |
156 | } | 133 | } |
diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c index b80cb5b5ebbd..2238ab916a06 100644 --- a/drivers/mtd/devices/spear_smi.c +++ b/drivers/mtd/devices/spear_smi.c | |||
@@ -510,10 +510,6 @@ static int spear_mtd_erase(struct mtd_info *mtd, struct erase_info *e_info) | |||
510 | if (!flash || !dev) | 510 | if (!flash || !dev) |
511 | return -ENODEV; | 511 | return -ENODEV; |
512 | 512 | ||
513 | /* do not allow erase past end of device */ | ||
514 | if (e_info->addr + e_info->len > flash->mtd.size) | ||
515 | return -EINVAL; | ||
516 | |||
517 | bank = flash->bank; | 513 | bank = flash->bank; |
518 | if (bank > dev->num_flashes - 1) { | 514 | if (bank > dev->num_flashes - 1) { |
519 | dev_err(&dev->pdev->dev, "Invalid Bank Num"); | 515 | dev_err(&dev->pdev->dev, "Invalid Bank Num"); |
@@ -573,10 +569,6 @@ static int spear_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
573 | if (!flash || !dev) | 569 | if (!flash || !dev) |
574 | return -ENODEV; | 570 | return -ENODEV; |
575 | 571 | ||
576 | /* do not allow reads past end of device */ | ||
577 | if (from + len > flash->mtd.size) | ||
578 | return -EINVAL; | ||
579 | |||
580 | if (flash->bank > dev->num_flashes - 1) { | 572 | if (flash->bank > dev->num_flashes - 1) { |
581 | dev_err(&dev->pdev->dev, "Invalid Bank Num"); | 573 | dev_err(&dev->pdev->dev, "Invalid Bank Num"); |
582 | return -EINVAL; | 574 | return -EINVAL; |
@@ -678,10 +670,6 @@ static int spear_mtd_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
678 | if (!len) | 670 | if (!len) |
679 | return 0; | 671 | return 0; |
680 | 672 | ||
681 | /* do not allow write past end of page */ | ||
682 | if (to + len > flash->mtd.size) | ||
683 | return -EINVAL; | ||
684 | |||
685 | if (flash->bank > dev->num_flashes - 1) { | 673 | if (flash->bank > dev->num_flashes - 1) { |
686 | dev_err(&dev->pdev->dev, "Invalid Bank Num"); | 674 | dev_err(&dev->pdev->dev, "Invalid Bank Num"); |
687 | return -EINVAL; | 675 | return -EINVAL; |
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c index 8b9ffafcc401..99d4a3c510d7 100644 --- a/drivers/mtd/devices/sst25l.c +++ b/drivers/mtd/devices/sst25l.c | |||
@@ -175,9 +175,6 @@ static int sst25l_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
175 | int err; | 175 | int err; |
176 | 176 | ||
177 | /* Sanity checks */ | 177 | /* Sanity checks */ |
178 | if (instr->addr + instr->len > flash->mtd.size) | ||
179 | return -EINVAL; | ||
180 | |||
181 | if ((uint32_t)instr->len % mtd->erasesize) | 178 | if ((uint32_t)instr->len % mtd->erasesize) |
182 | return -EINVAL; | 179 | return -EINVAL; |
183 | 180 | ||
@@ -227,9 +224,6 @@ static int sst25l_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
227 | if (len == 0) | 224 | if (len == 0) |
228 | return 0; | 225 | return 0; |
229 | 226 | ||
230 | if (from + len > flash->mtd.size) | ||
231 | return -EINVAL; | ||
232 | |||
233 | if (retlen) | 227 | if (retlen) |
234 | *retlen = 0; | 228 | *retlen = 0; |
235 | 229 | ||
@@ -278,9 +272,6 @@ static int sst25l_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
278 | if (!len) | 272 | if (!len) |
279 | return 0; | 273 | return 0; |
280 | 274 | ||
281 | if (to + len > flash->mtd.size) | ||
282 | return -EINVAL; | ||
283 | |||
284 | if ((uint32_t)to % mtd->writesize) | 275 | if ((uint32_t)to % mtd->writesize) |
285 | return -EINVAL; | 276 | return -EINVAL; |
286 | 277 | ||