summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Goodbody <[email protected]>2025-07-01 17:12:44 +0100
committerTom Rini <[email protected]>2025-10-28 12:11:09 -0600
commita5c83da3ccb372133fdbe43e0a8e65e06b3291e8 (patch)
treecbffded59f0ceedbec18b79381c5e11d92b515bd
parentce1bdedd2f4b3c5c8c76fbf2fc1a234fca470573 (diff)
mtd: nand: Prevent dereference of NULL pointer
In nand_wait_ready there is a loop that includes a NULL check for chip->dev_ready before it is dereferenced. Use a NULL check once the loop is exited as well to cover the case where it exits due to a timeout and it is therefore not known if chip->dev_ready is NULL or not. This issue found by Smatch. Signed-off-by: Andrew Goodbody <[email protected]> Reviewed-by: Michael Trimarchi <[email protected]>
-rw-r--r--drivers/mtd/nand/raw/nand_base.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index d3d1b93947b..48e3685d995 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -566,7 +566,7 @@ void nand_wait_ready(struct mtd_info *mtd)
break;
}
- if (!chip->dev_ready(mtd))
+ if (!chip->dev_ready || !chip->dev_ready(mtd))
pr_warn("timeout while waiting for chip to become ready\n");
}
EXPORT_SYMBOL_GPL(nand_wait_ready);