From d092f5fb56a8a873f1d7fdf0213d006f35aa7ebf Mon Sep 17 00:00:00 2001 From: Han Xu Date: Wed, 31 Mar 2021 14:47:55 -0500 Subject: [PATCH] LF-3626: mtd: nand: gpmi: fix the explicit null dereference issue A potiential null pointer dereference issue may occur in gpmi_nfc_exec_op(), found by coverity, CID 9000785. In the for loop, if loop continues in NAND_OP_CMD_INSTR case, the desc pointer may leave as null, so move the pointer sanity check outside the loop. Signed-off-by: Han Xu Reviewed-by: Frank Li --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index d7a157a9038c..77b359262ddc 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -2598,11 +2598,11 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip, &direct); break; } + } - if (!desc) { - ret = -ENXIO; - goto unmap; - } + if (!desc) { + ret = -ENXIO; + goto unmap; } dev_dbg(this->dev, "%s setup done\n", __func__); -- 2.17.1