* [PATCH] UBI: Ensure index is positive
@ 2009-11-03 19:49 Roel Kluin
2009-11-11 7:57 ` Artem Bityutskiy
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-11-03 19:49 UTC (permalink / raw)
To: David Woodhouse, linux-mtd, Andrew Morton, LKML
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>
---
drivers/mtd/mtdcore.c | 2 +-
drivers/mtd/nand/fsl_upm.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 467a4f1..c356c0a 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;
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index d120cd8..071a60c 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)
if (mchip_nr == -1) {
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;
chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr];
chip->IO_ADDR_W = chip->IO_ADDR_R;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] UBI: Ensure index is positive
2009-11-03 19:49 [PATCH] UBI: Ensure index is positive Roel Kluin
@ 2009-11-11 7:57 ` Artem Bityutskiy
0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2009-11-11 7:57 UTC (permalink / raw)
To: Roel Kluin; +Cc: linux-mtd, Andrew Morton, David Woodhouse, LKML
On Tue, 2009-11-03 at 20:49 +0100, Roel Kluin wrote:
> 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>
This is not UBI, this is mtd. I've amended the subject and pushed this
patch to my l2-mtd-2.6, thanks.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-11 7:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-03 19:49 [PATCH] UBI: Ensure index is positive Roel Kluin
2009-11-11 7:57 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).