From 84de0b493ff62993c4047dd15318cc23f83923d3 Mon Sep 17 00:00:00 2001 From: Manish Narani Date: Thu, 25 Oct 2018 11:36:56 +0530 Subject: [PATCH] EDAC, synopsys: Add error handling for the of_device_get_match_data() result 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 Signed-off-by: Borislav Petkov CC: Mauro Carvalho Chehab CC: Michal Simek 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 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 1c3795dd7b82..0005ef387af6 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -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; -- 2.30.2