diff options
| author | Dario Binacchi <[email protected]> | 2023-11-02 12:38:22 +0100 |
|---|---|---|
| committer | Dario Binacchi <[email protected]> | 2024-01-15 08:58:24 +0100 |
| commit | cbfff3b123a169e249c41b071e4065bce3a2e18a (patch) | |
| tree | 9212e2a9f0a9687ed3043ca751062b10bbab8a5a /drivers | |
| parent | 6b3d175928417f55537fe271df983f7ed52915f3 (diff) | |
mtd: nand: check nand_mtd_to_devnum() argument
If the "mtd" parameter is NULL, the search will definitely yield a
negative result. In that case, it's better to exit immediately.
Signed-off-by: Dario Binacchi <[email protected]>
Reviewed-by: Michael Trimarchi <[email protected]>
Link: https://lore.kernel.org/all/[email protected]
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/mtd/nand/raw/nand.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/mtd/nand/raw/nand.c b/drivers/mtd/nand/raw/nand.c index c1a0ebe6486..b591170346d 100644 --- a/drivers/mtd/nand/raw/nand.c +++ b/drivers/mtd/nand/raw/nand.c @@ -41,8 +41,11 @@ int nand_mtd_to_devnum(struct mtd_info *mtd) { int i; + if (!mtd) + return -ENODEV; + for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { - if (mtd && get_nand_dev_by_index(i) == mtd) + if (get_nand_dev_by_index(i) == mtd) return i; } |
