[alsa-devel] [PATCH 2/2] ASoC: rt5645: Fix potential crash in jd function
Bard Liao
bardliao at realtek.com
Tue Nov 18 09:50:19 CET 2014
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 at realtek.com>
Signed-off-by: Fang, Yang A <yang.a.fang at intel.com>
---
sound/soc/codecs/rt5645.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index a7789a8..bbf2005c 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -2209,6 +2209,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 0;
+ }
gpio_state = gpio_get_value(rt5645->pdata.hp_det_gpio);
dev_dbg(codec->dev, "gpio = %d(%d)\n", rt5645->pdata.hp_det_gpio,
--
1.8.1.1.439.g50a6b54
More information about the Alsa-devel
mailing list