* [PATCH v2] mtd: rawnand: tegra: check bounds of die_nr properly
@ 2018-07-17 8:46 Marcel Ziswiler
2018-07-18 7:45 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Marcel Ziswiler @ 2018-07-17 8:46 UTC (permalink / raw)
To: linux-mtd, linux-tegra, linux-kernel, Stefan Agner,
boris.brezillon, miquel.raynal
Cc: dev, mirza.krak, benjamin.lindqvist, krzk, marek.vasut, richard,
digetx, computersforpeace, dwmw2, dan.carpenter, Marcel Ziswiler,
Thierry Reding, Jonathan Hunter
From: Stefan Agner <stefan@agner.ch>
The Tegra driver currently only support a single chip select, hence
check boundaries accordingly. This fixes a off by one issue catched
with Smatch:
drivers/mtd/nand/raw/tegra_nand.c:476 tegra_nand_select_chip()
warn: array off by one? 'nand->cs[die_nr]'
Also warn in case the stack asks for a chip select we currently do
not support.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
---
Changes in v2:
- Fixed comparison between signed integer die_nr and unsigned ARRAY_SIZE.
drivers/mtd/nand/raw/tegra_nand.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/raw/tegra_nand.c b/drivers/mtd/nand/raw/tegra_nand.c
index 9f7de36be893..56c0aa1bc81f 100644
--- a/drivers/mtd/nand/raw/tegra_nand.c
+++ b/drivers/mtd/nand/raw/tegra_nand.c
@@ -468,7 +468,9 @@ static void tegra_nand_select_chip(struct mtd_info *mtd, int die_nr)
struct tegra_nand_chip *nand = to_tegra_chip(chip);
struct tegra_nand_controller *ctrl = to_tegra_ctrl(chip->controller);
- if (die_nr < 0 || die_nr > 1) {
+ WARN_ON(die_nr >= (int)ARRAY_SIZE(nand->cs));
+
+ if (die_nr < 0 || die_nr > 0) {
ctrl->cur_cs = -1;
return;
}
--
2.14.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] mtd: rawnand: tegra: check bounds of die_nr properly
2018-07-17 8:46 [PATCH v2] mtd: rawnand: tegra: check bounds of die_nr properly Marcel Ziswiler
@ 2018-07-18 7:45 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2018-07-18 7:45 UTC (permalink / raw)
To: Marcel Ziswiler
Cc: linux-mtd, linux-tegra, linux-kernel, Stefan Agner,
boris.brezillon, dev, mirza.krak, benjamin.lindqvist, krzk,
marek.vasut, richard, digetx, computersforpeace, dwmw2,
dan.carpenter, Marcel Ziswiler, Thierry Reding, Jonathan Hunter
Hi Marcel,
Marcel Ziswiler <marcel@ziswiler.com> wrote on Tue, 17 Jul 2018
10:46:18 +0200:
> From: Stefan Agner <stefan@agner.ch>
>
> The Tegra driver currently only support a single chip select, hence
> check boundaries accordingly. This fixes a off by one issue catched
> with Smatch:
> drivers/mtd/nand/raw/tegra_nand.c:476 tegra_nand_select_chip()
> warn: array off by one? 'nand->cs[die_nr]'
>
> Also warn in case the stack asks for a chip select we currently do
> not support.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Applied on nand/next in place of the previous one (with my SoB after
yours).
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-18 7:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 8:46 [PATCH v2] mtd: rawnand: tegra: check bounds of die_nr properly Marcel Ziswiler
2018-07-18 7:45 ` Miquel Raynal
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).