From: Shailendra Verma <shailendra.v@samsung.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
p.shailesh@samsung.com, ashish.kalra@samsung.com,
Shailendra Verma <shailendra.v@samsung.com>,
Shailendra Verma <shailendra.capricorn@gmail.com>
Subject: [PATCH] sound: soc: davinci - Fix possible NULL derefrence.
Date: Fri, 27 Jan 2017 16:40:57 +0530 [thread overview]
Message-ID: <1485515457-3055-1-git-send-email-shailendra.v@samsung.com> (raw)
In-Reply-To: <CGME20170127111104epcas1p2810feef80b04b21983efd16c00b1b651@epcas1p2.samsung.com>
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
sound/soc/davinci/davinci-evm.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 731fb0d..7a369e0 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -358,13 +358,20 @@ static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd)
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);
--
1.7.9.5
next parent reply other threads:[~2017-01-27 11:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170127111104epcas1p2810feef80b04b21983efd16c00b1b651@epcas1p2.samsung.com>
2017-01-27 11:10 ` Shailendra Verma [this message]
2017-01-27 11:58 ` Mark Brown
2017-01-27 11:58 ` Mark Brown
2017-01-31 20:02 ` Applied "ASoC: davinci - Fix possible NULL derefrence." to the asoc tree Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485515457-3055-1-git-send-email-shailendra.v@samsung.com \
--to=shailendra.v@samsung.com \
--cc=alsa-devel@alsa-project.org \
--cc=ashish.kalra@samsung.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=p.shailesh@samsung.com \
--cc=perex@perex.cz \
--cc=shailendra.capricorn@gmail.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®