aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-11-03 14:49:18 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-11-30 04:50:46 -0500
commit35016dd7e92cf0eb5ae2e811445dd52320c348d0 (patch)
treeb836cd329ed1fae21e323f9eee9c15c012423a62 /drivers/mtd
parent61c3506c2cabe58bcdfe438d1e57b62994db1616 (diff)
mtd: ensure index is positive
The index is signed, make sure it is not negative when we read the array element. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/mtdcore.c2
-rw-r--r--drivers/mtd/nand/fsl_upm.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 467a4f177bfb..c356c0a30c3e 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -447,7 +447,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
447 for (i=0; i< MAX_MTD_DEVICES; i++) 447 for (i=0; i< MAX_MTD_DEVICES; i++)
448 if (mtd_table[i] == mtd) 448 if (mtd_table[i] == mtd)
449 ret = mtd_table[i]; 449 ret = mtd_table[i];
450 } else if (num < MAX_MTD_DEVICES) { 450 } else if (num >= 0 && num < MAX_MTD_DEVICES) {
451 ret = mtd_table[num]; 451 ret = mtd_table[num];
452 if (mtd && mtd != ret) 452 if (mtd && mtd != ret)
453 ret = NULL; 453 ret = NULL;
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index d120cd8d7267..071a60cb4204 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -112,7 +112,7 @@ static void fun_select_chip(struct mtd_info *mtd, int mchip_nr)
112 112
113 if (mchip_nr == -1) { 113 if (mchip_nr == -1) {
114 chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE); 114 chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE);
115 } else if (mchip_nr >= 0) { 115 } else if (mchip_nr >= 0 && mchip_nr < NAND_MAX_CHIPS) {
116 fun->mchip_number = mchip_nr; 116 fun->mchip_number = mchip_nr;
117 chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr]; 117 chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr];
118 chip->IO_ADDR_W = chip->IO_ADDR_R; 118 chip->IO_ADDR_W = chip->IO_ADDR_R;