From 75945896a2f4a7ebfc3402443f99ac32f629ee96 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Tue, 9 Dec 2014 10:14:45 +0800 Subject: ASoC: rt5645: Fix potential crash in jd function If no one defined the rt5645->pdata.hp_det_gpio in coreboot/bios. It will cause kernel to reboot because rt5645->pdata.hp_det_gpio is 0. So it is worth to add a check in rt5645_jack_detect. Signed-off-by: Bard Liao Signed-off-by: Fang, Yang A Signed-off-by: Mark Brown --- sound/soc/codecs/rt5645.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index d16331e0b64d..c901ef6ba69b 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -2113,6 +2113,10 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int gpio_state, jack_type = 0; unsigned int val; + if (!gpio_is_valid(rt5645->pdata.hp_det_gpio)) { + dev_err(codec->dev, "invalid gpio\n"); + return -EINVAL; + } gpio_state = gpio_get_value(rt5645->pdata.hp_det_gpio); dev_dbg(codec->dev, "gpio = %d(%d)\n", rt5645->pdata.hp_det_gpio, -- cgit v1.2.3-59-g8ed1b