EDAC, synopsys: Add error handling for the of_device_get_match_data() result
authorManish Narani <manish.narani@xilinx.com>
Thu, 25 Oct 2018 06:06:56 +0000 (11:36 +0530)
committerBorislav Petkov <bp@suse.de>
Mon, 5 Nov 2018 12:36:20 +0000 (13:36 +0100)
The function of_device_get_match_data() can return NULL in case of
error. Add error handling for the same in the mc_probe() function.

Signed-off-by: Manish Narani <manish.narani@xilinx.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
CC: Mauro Carvalho Chehab <mchehab@kernel.org>
CC: Michal Simek <michal.simek@xilinx.com>
CC: amit.kucheria@linaro.org
CC: devicetree@vger.kernel.org
CC: leoyang.li@nxp.com
CC: linux-arm-kernel@lists.infradead.org
CC: linux-edac <linux-edac@vger.kernel.org>
CC: mark.rutland@arm.com
CC: robh+dt@kernel.org
CC: sudeep.holla@arm.com
Link: http://lkml.kernel.org/r/1540447621-22870-2-git-send-email-manish.narani@xilinx.com
drivers/edac/synopsys_edac.c

index 1c3795dd7b82579e886ecd113acb226395b24fb1..0005ef387af64ee01f744033cb322b560c62a929 100644 (file)
@@ -477,6 +477,9 @@ static int mc_probe(struct platform_device *pdev)
                return PTR_ERR(baseaddr);
 
        p_data = of_device_get_match_data(&pdev->dev);
+       if (!p_data)
+               return -ENODEV;
+
        if (!p_data->get_ecc_state(baseaddr)) {
                edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n");
                return -ENXIO;