aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-05 17:57:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-05 17:57:04 -0400
commit5136a6c0fd5b26bbf39ad761cf7a4fc563ad83a3 (patch)
tree7c905238cb2c5c9cd959cd652010b0eaf5f91db3 /drivers
parente505a8d5f96a84f3043ce0c4eaee8f045996896c (diff)
parentbc8cec0dff072f1a45ce7f6b2c5234bb3411ac51 (diff)
Merge git://git.infradead.org/~dwmw2/mtd-2.6.31
* git://git.infradead.org/~dwmw2/mtd-2.6.31: JFFS2: add missing verify buffer allocation/deallocation mtd: nftl: fix offset alignments mtd: nftl: write support is broken mtd: m25p80: fix null pointer dereference bug
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/devices/m25p80.c2
-rw-r--r--drivers/mtd/nftlcore.c15
2 files changed, 10 insertions, 7 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index ae5fe91867e1..10ed195c0c1c 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -736,7 +736,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
736 flash->partitioned = 1; 736 flash->partitioned = 1;
737 return add_mtd_partitions(&flash->mtd, parts, nr_parts); 737 return add_mtd_partitions(&flash->mtd, parts, nr_parts);
738 } 738 }
739 } else if (data->nr_parts) 739 } else if (data && data->nr_parts)
740 dev_warn(&spi->dev, "ignoring %d default partitions on %s\n", 740 dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
741 data->nr_parts, data->name); 741 data->nr_parts, data->name);
742 742
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index fb86cacd5bdb..1002e1882996 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -135,16 +135,17 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)
135int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, 135int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
136 size_t *retlen, uint8_t *buf) 136 size_t *retlen, uint8_t *buf)
137{ 137{
138 loff_t mask = mtd->writesize - 1;
138 struct mtd_oob_ops ops; 139 struct mtd_oob_ops ops;
139 int res; 140 int res;
140 141
141 ops.mode = MTD_OOB_PLACE; 142 ops.mode = MTD_OOB_PLACE;
142 ops.ooboffs = offs & (mtd->writesize - 1); 143 ops.ooboffs = offs & mask;
143 ops.ooblen = len; 144 ops.ooblen = len;
144 ops.oobbuf = buf; 145 ops.oobbuf = buf;
145 ops.datbuf = NULL; 146 ops.datbuf = NULL;
146 147
147 res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); 148 res = mtd->read_oob(mtd, offs & ~mask, &ops);
148 *retlen = ops.oobretlen; 149 *retlen = ops.oobretlen;
149 return res; 150 return res;
150} 151}
@@ -155,16 +156,17 @@ int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
155int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len, 156int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
156 size_t *retlen, uint8_t *buf) 157 size_t *retlen, uint8_t *buf)
157{ 158{
159 loff_t mask = mtd->writesize - 1;
158 struct mtd_oob_ops ops; 160 struct mtd_oob_ops ops;
159 int res; 161 int res;
160 162
161 ops.mode = MTD_OOB_PLACE; 163 ops.mode = MTD_OOB_PLACE;
162 ops.ooboffs = offs & (mtd->writesize - 1); 164 ops.ooboffs = offs & mask;
163 ops.ooblen = len; 165 ops.ooblen = len;
164 ops.oobbuf = buf; 166 ops.oobbuf = buf;
165 ops.datbuf = NULL; 167 ops.datbuf = NULL;
166 168
167 res = mtd->write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); 169 res = mtd->write_oob(mtd, offs & ~mask, &ops);
168 *retlen = ops.oobretlen; 170 *retlen = ops.oobretlen;
169 return res; 171 return res;
170} 172}
@@ -177,17 +179,18 @@ int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
177static int nftl_write(struct mtd_info *mtd, loff_t offs, size_t len, 179static int nftl_write(struct mtd_info *mtd, loff_t offs, size_t len,
178 size_t *retlen, uint8_t *buf, uint8_t *oob) 180 size_t *retlen, uint8_t *buf, uint8_t *oob)
179{ 181{
182 loff_t mask = mtd->writesize - 1;
180 struct mtd_oob_ops ops; 183 struct mtd_oob_ops ops;
181 int res; 184 int res;
182 185
183 ops.mode = MTD_OOB_PLACE; 186 ops.mode = MTD_OOB_PLACE;
184 ops.ooboffs = offs; 187 ops.ooboffs = offs & mask;
185 ops.ooblen = mtd->oobsize; 188 ops.ooblen = mtd->oobsize;
186 ops.oobbuf = oob; 189 ops.oobbuf = oob;
187 ops.datbuf = buf; 190 ops.datbuf = buf;
188 ops.len = len; 191 ops.len = len;
189 192
190 res = mtd->write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); 193 res = mtd->write_oob(mtd, offs & ~mask, &ops);
191 *retlen = ops.retlen; 194 *retlen = ops.retlen;
192 return res; 195 return res;
193} 196}