[PATCH v2] mtd: rawnand: fix condition in 'nand_select_target()'

Arseniy Krasnov posted 1 patch 1 month, 1 week ago
drivers/mtd/nand/raw/nand_base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] mtd: rawnand: fix condition in 'nand_select_target()'
Posted by Arseniy Krasnov 1 month, 1 week ago
'cs' here must be in range [0:nanddev_ntargets[.

Cc: stable@vger.kernel.org
Fixes: 32813e288414 ("mtd: rawnand: Get rid of chip->numchips")
Signed-off-by: Arseniy Krasnov <avkrasnov@rulkc.org>
---
 Changelog v1->v2:
 * Commit message typo updates.

 drivers/mtd/nand/raw/nand_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 13e4060bd1b6a..edfee22f15a73 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -174,7 +174,7 @@ void nand_select_target(struct nand_chip *chip, unsigned int cs)
 	 * cs should always lie between 0 and nanddev_ntargets(), when that's
 	 * not the case it's a bug and the caller should be fixed.
 	 */
-	if (WARN_ON(cs > nanddev_ntargets(&chip->base)))
+	if (WARN_ON(cs >= nanddev_ntargets(&chip->base)))
 		return;
 
 	chip->cur_cs = cs;
-- 
2.47.3
Re: [PATCH v2] mtd: rawnand: fix condition in 'nand_select_target()'
Posted by Miquel Raynal 2 weeks, 3 days ago
On Tue, 05 May 2026 11:30:30 +0300, Arseniy Krasnov wrote:
> 'cs' here must be in range [0:nanddev_ntargets[.
> 
> 

Applied to nand/next, thanks!

[1/1] mtd: rawnand: fix condition in 'nand_select_target()'
      commit: 8507c2cc9e4fa402401819f44d1e8a5ef4d11d8b

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl