summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorBard Liao <bardliao@realtek.com>2014-12-09 02:14:45 (GMT)
committerMark Brown <broonie@kernel.org>2014-12-09 16:10:45 (GMT)
commit75945896a2f4a7ebfc3402443f99ac32f629ee96 (patch)
tree6595e5f653e18fbe5f3cda3f27896285dbd49c6a /sound/soc
parentdf078d291d9b50e3ccfb8f030f85de701696a5ad (diff)
downloadlinux-75945896a2f4a7ebfc3402443f99ac32f629ee96.tar.xz
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 <bardliao@realtek.com> Signed-off-by: Fang, Yang A <yang.a.fang@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/rt5645.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index d16331e..c901ef6 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,