ASoC: jack: Fix race in snd_soc_jack_add_gpios
[openwrt/openwrt.git] / target / linux / generic-2.6 / patches-2.6.30 / 780-fix-race-in-snd_soc_jack_add_gpios.patch
1 From d8d0421cddc6ecdec166612d914b8edbcdb96ed0 Mon Sep 17 00:00:00 2001
2 From: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Fri, 31 Jul 2009 20:33:31 +0200
4 Subject: [PATCH] ASoC: jack: Fix race in snd_soc_jack_add_gpios
5
6 The irq can fire as soon as it has been requested, thus all fields accessed
7 from within the irq handler must be initialized prior to requesting the irq.
8
9 Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
10 ---
11 The patch is against alsa-kernel/master but I guess something similar should also
12 go into 2.6.31.
13
14 sound/soc/soc-jack.c | 6 +++---
15 1 files changed, 3 insertions(+), 3 deletions(-)
16
17 diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
18 index 4aa7d8f..1d455ab 100644
19 --- a/sound/soc/soc-jack.c
20 +++ b/sound/soc/soc-jack.c
21 @@ -221,6 +221,9 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
22 if (ret)
23 goto err;
24
25 + INIT_WORK(&gpios[i].work, gpio_work);
26 + gpios[i].jack = jack;
27 +
28 ret = request_irq(gpio_to_irq(gpios[i].gpio),
29 gpio_handler,
30 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
31 @@ -234,9 +237,6 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
32 gpio_export(gpios[i].gpio, false);
33 #endif
34
35 - INIT_WORK(&gpios[i].work, gpio_work);
36 - gpios[i].jack = jack;
37 -
38 /* Update initial jack status */
39 snd_soc_jack_gpio_detect(&gpios[i]);
40 }
41 --
42 1.5.6.5
43