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:

committed by
David Woodhouse

parent
61c3506c2c
commit
35016dd7e9
@@ -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;
|
||||
|
Reference in New Issue
Block a user