mtd: nand: Prevent dereference of NULL pointer
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Tue, 1 Jul 2025 16:12:44 +0000 (17:12 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 28 Oct 2025 18:11:09 +0000 (12:11 -0600)
commita5c83da3ccb372133fdbe43e0a8e65e06b3291e8
treecbffded59f0ceedbec18b79381c5e11d92b515bd
parentce1bdedd2f4b3c5c8c76fbf2fc1a234fca470573
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 <andrew.goodbody@linaro.org>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
drivers/mtd/nand/raw/nand_base.c