mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
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>
This commit is contained in:
parent
61c3506c2c
commit
35016dd7e9
2 changed files with 2 additions and 2 deletions
|
@ -447,7 +447,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
|
||||||
for (i=0; i< MAX_MTD_DEVICES; i++)
|
for (i=0; i< MAX_MTD_DEVICES; i++)
|
||||||
if (mtd_table[i] == mtd)
|
if (mtd_table[i] == mtd)
|
||||||
ret = mtd_table[i];
|
ret = mtd_table[i];
|
||||||
} else if (num < MAX_MTD_DEVICES) {
|
} else if (num >= 0 && num < MAX_MTD_DEVICES) {
|
||||||
ret = mtd_table[num];
|
ret = mtd_table[num];
|
||||||
if (mtd && mtd != ret)
|
if (mtd && mtd != ret)
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
|
|
@ -112,7 +112,7 @@ static void fun_select_chip(struct mtd_info *mtd, int mchip_nr)
|
||||||
|
|
||||||
if (mchip_nr == -1) {
|
if (mchip_nr == -1) {
|
||||||
chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE);
|
chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE);
|
||||||
} else if (mchip_nr >= 0) {
|
} else if (mchip_nr >= 0 && mchip_nr < NAND_MAX_CHIPS) {
|
||||||
fun->mchip_number = mchip_nr;
|
fun->mchip_number = mchip_nr;
|
||||||
chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr];
|
chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr];
|
||||||
chip->IO_ADDR_W = chip->IO_ADDR_R;
|
chip->IO_ADDR_W = chip->IO_ADDR_R;
|
||||||
|
|
Loading…
Reference in a new issue