From: Han Xu Date: Wed, 31 Mar 2021 19:47:55 +0000 (-0500) Subject: LF-3626: mtd: nand: gpmi: fix the explicit null dereference issue X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~110 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=d092f5fb56a8a873f1d7fdf0213d006f35aa7ebf;p=linux.git 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 --- 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__);