From: LABBE Corentin <clabbe.montjoie@gmail.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org,
kuninori.morimoto.gx@renesas.com, lgirdwood@gmail.com,
perex@perex.cz, tiwai@suse.com
Cc: LABBE Corentin <clabbe.montjoie@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] ASoC: rsnd: fix a possible NULL dereference
Date: Wed, 25 Nov 2015 13:49:35 +0100 [thread overview]
Message-ID: <1448455796-27315-1-git-send-email-clabbe.montjoie@gmail.com> (raw)
of_match_device could return NULL, and so cause a NULL pointer
dereference later.
Even if the probability of this case is very low, fixing it made
static analyzers happy.
Solving this with of_device_get_match_data made also code simplier.
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
sound/soc/sh/rcar/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index deed48e..54cc44c 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1204,7 +1204,6 @@ static int rsnd_probe(struct platform_device *pdev)
struct rsnd_priv *priv;
struct device *dev = &pdev->dev;
struct rsnd_dai *rdai;
- const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev);
const struct rsnd_of_data *of_data;
int (*probe_func[])(struct platform_device *pdev,
const struct rsnd_of_data *of_data,
@@ -1221,11 +1220,13 @@ static int rsnd_probe(struct platform_device *pdev)
};
int ret, i;
+ of_data = of_device_get_match_data(dev);
+ if (!of_data)
+ return 1;
info = devm_kzalloc(&pdev->dev, sizeof(struct rcar_snd_info),
GFP_KERNEL);
if (!info)
return -ENOMEM;
- of_data = of_id->data;
/*
* init priv data
--
2.4.10
next reply other threads:[~2015-11-25 12:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-25 12:49 LABBE Corentin [this message]
2015-11-25 23:46 ` Kuninori Morimoto
2015-11-26 7:17 ` LABBE Corentin
2015-11-30 16:38 ` 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=1448455796-27315-1-git-send-email-clabbe.montjoie@gmail.com \
--to=clabbe.montjoie@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--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®