diff mbox

[1/2] ASoC: rt286: Fix potencial crash in jd function

Message ID 1423125634-8367-1-git-send-email-bardliao@realtek.com (mailing list archive)
State Accepted
Commit 28d1ad09c50c758d3e295fa7ff90a4712e1254ea
Headers show

Commit Message

Bard Liao Feb. 5, 2015, 8:40 a.m. UTC
We assign rt286->codec in rt286_probe. If rt286_jack_detect is
invoked before rt286_probe, rt286->codec will be NULL and cause
a kernel panic.

Signed-off-by: Bard Liao <bardliao@realtek.com>
---
 sound/soc/codecs/rt286.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Mark Brown Feb. 5, 2015, 6:17 p.m. UTC | #1
On Thu, Feb 05, 2015 at 04:40:33PM +0800, Bard Liao wrote:
> We assign rt286->codec in rt286_probe. If rt286_jack_detect is
> invoked before rt286_probe, rt286->codec will be NULL and cause
> a kernel panic.

Applied, thanks.
diff mbox

Patch

diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 2eafbcf..3d69cb4 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -306,6 +306,8 @@  static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic)
 	*hp = false;
 	*mic = false;
 
+	if (!rt286->codec)
+		return -EINVAL;
 	if (rt286->pdata.cbj_en) {
 		regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf);
 		*hp = buf & 0x80000000;