From: Dan Carpenter <error27@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>,
Mike Frysinger <vapier@gentoo.org>,
Anton Vorontsov <avorontsov@mvista.com>,
kernel-janitors@vger.kernel.org, Gabor Juhos <juhosg@openwrt.org>,
linux-mtd@lists.infradead.org
Subject: [patch 2/2] mtd/m25p80: fix test for end of loop
Date: Thu, 12 Aug 2010 07:58:27 +0000 [thread overview]
Message-ID: <20100812075827.GO645@bicker> (raw)
"plat_id" is always non-NULL here. There is a zero element on the end
of the m25p_ids[] array and if we hit the end of the loop then plat_id
points to that.
This would lead to a NULL pointer dereference later on in the function.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 83c9086..6f512b5 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -793,7 +793,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
break;
}
- if (plat_id)
+ if (i < ARRAY_SIZE(m25p_ids) - 1)
id = plat_id;
else
dev_warn(&spi->dev, "unrecognized id %s\n", data->type);
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>,
Mike Frysinger <vapier@gentoo.org>,
Anton Vorontsov <avorontsov@mvista.com>,
kernel-janitors@vger.kernel.org, Gabor Juhos <juhosg@openwrt.org>,
linux-mtd@lists.infradead.org
Subject: [patch 2/2] mtd/m25p80: fix test for end of loop
Date: Thu, 12 Aug 2010 09:58:27 +0200 [thread overview]
Message-ID: <20100812075827.GO645@bicker> (raw)
"plat_id" is always non-NULL here. There is a zero element on the end
of the m25p_ids[] array and if we hit the end of the loop then plat_id
points to that.
This would lead to a NULL pointer dereference later on in the function.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 83c9086..6f512b5 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -793,7 +793,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
break;
}
- if (plat_id)
+ if (i < ARRAY_SIZE(m25p_ids) - 1)
id = plat_id;
else
dev_warn(&spi->dev, "unrecognized id %s\n", data->type);
next reply other threads:[~2010-08-12 7:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-12 7:58 Dan Carpenter [this message]
2010-08-12 7:58 ` [patch 2/2] mtd/m25p80: fix test for end of loop Dan Carpenter
2010-08-12 11:17 ` Anton Vorontsov
2010-08-12 11:17 ` Anton Vorontsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100812075827.GO645@bicker \
--to=error27@gmail.com \
--cc=Artem.Bityutskiy@nokia.com \
--cc=avorontsov@mvista.com \
--cc=dwmw2@infradead.org \
--cc=juhosg@openwrt.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.