aboutsummaryrefslogtreecommitdiff
path: root/drivers/mtd/mtdcore.c
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-11-03 20:49:18 +0100
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-11-30 09:50:46 +0000
commit35016dd7e92cf0eb5ae2e811445dd52320c348d0 (patch)
treeb836cd329ed1fae21e323f9eee9c15c012423a62 /drivers/mtd/mtdcore.c
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/mtdcore.c')
-rw-r--r--drivers/mtd/mtdcore.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 467a4f177bf..c356c0a30c3 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)
for (i=0; i< MAX_MTD_DEVICES; i++)
if (mtd_table[i] == mtd)
ret = mtd_table[i];
- } else if (num < MAX_MTD_DEVICES) {
+ } else if (num >= 0 && num < MAX_MTD_DEVICES) {
ret = mtd_table[num];
if (mtd && mtd != ret)
ret = NULL;