From: Shailendra Verma Date: Fri, 27 Jan 2017 11:10:57 +0000 (+0530) Subject: ASoC: davinci - Fix possible NULL derefrence. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3f81d9aa80ae4b513416440e416a6486ef2ad817;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git ASoC: davinci - Fix possible NULL derefrence. of_match_device could return NULL, and so can cause a NULL pointer dereference later. Signed-off-by: Shailendra Verma Signed-off-by: Mark Brown --- diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 731fb0d86c6a..7a369e0f2093 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -358,13 +358,20 @@ static struct snd_soc_card evm_soc_card = { static int davinci_evm_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - const struct of_device_id *match = - of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev); - struct snd_soc_dai_link *dai = (struct snd_soc_dai_link *) match->data; + const struct of_device_id *match; + struct snd_soc_dai_link *dai; struct snd_soc_card_drvdata_davinci *drvdata = NULL; struct clk *mclk; int ret = 0; + match = of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev); + if (!match) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } + + dai = (struct snd_soc_dai_link *) match->data; + evm_soc_card.dai_link = dai; dai->codec_of_node = of_parse_phandle(np, "ti,audio-codec", 0);