From: Aditya Pakki Date: Mon, 18 Mar 2019 23:24:34 +0000 (-0500) Subject: mtd: rawnand: vf610: Avoid a potential NULL pointer dereference X-Git-Tag: v5.15~6384^2~30^2~59 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f0ce4dfc5a35bcb21f26d5347f4797fdde52810;p=platform%2Fkernel%2Flinux-starfive.git mtd: rawnand: vf610: Avoid a potential NULL pointer dereference of_match_device can return NULL if there is no matching device. Avoid a potential NULL pointer dereference by checking for the return value and passing the error upstream. Signed-off-by: Aditya Pakki Signed-off-by: Miquel Raynal --- diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c index a662ca1..6d43ddb 100644 --- a/drivers/mtd/nand/raw/vf610_nfc.c +++ b/drivers/mtd/nand/raw/vf610_nfc.c @@ -850,6 +850,9 @@ static int vf610_nfc_probe(struct platform_device *pdev) } of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); + if (!of_id) + return -ENODEV; + nfc->variant = (enum vf610_nfc_variant)of_id->data; for_each_available_child_of_node(nfc->dev->of_node, child) {