From: Takashi Iwai <tiwai@suse.de>
To: "Olivier Moysan" <olivier.moysan@st.com>
Cc: <alsa-devel@alsa-project.org>, <mark.rutland@arm.com>,
<lgirdwood@gmail.com>, <mcoquelin.stm32@gmail.com>,
<broonie@kernel.org>, <robh@kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <perex@perex.cz>,
<alexandre.torgue@st.com>, <kernel@stlinux.com>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<arnaud.pouliquen@st.com>, <benjamin.gaignard@st.com>
Subject: Re: [INTERNAL][PATCH 4/7] ASoC: stm32: sai: fix stop management in isr
Date: Thu, 26 Oct 2017 17:32:15 +0200 [thread overview]
Message-ID: <s5hmv4ekjr4.wl-tiwai@suse.de> (raw)
In-Reply-To: <1508418203-16840-5-git-send-email-olivier.moysan@st.com>
On Thu, 19 Oct 2017 15:03:20 +0200,
Olivier Moysan wrote:
>
> Add check on substream validity.
>
> Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
> ---
> sound/soc/stm/stm32_sai_sub.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
> index 2af397d..815ef10 100644
> --- a/sound/soc/stm/stm32_sai_sub.c
> +++ b/sound/soc/stm/stm32_sai_sub.c
> @@ -184,7 +184,6 @@ static bool stm32_sai_sub_writeable_reg(struct device *dev, unsigned int reg)
> static irqreturn_t stm32_sai_isr(int irq, void *devid)
> {
> struct stm32_sai_sub_data *sai = (struct stm32_sai_sub_data *)devid;
> - struct snd_pcm_substream *substream = sai->substream;
> struct platform_device *pdev = sai->pdev;
> unsigned int sr, imr, flags;
> snd_pcm_state_t status = SNDRV_PCM_STATE_RUNNING;
> @@ -199,6 +198,11 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
> regmap_update_bits(sai->regmap, STM_SAI_CLRFR_REGX, SAI_XCLRFR_MASK,
> SAI_XCLRFR_MASK);
>
> + if (!sai->substream) {
> + dev_err(&pdev->dev, "Device stopped. Spurious IRQ 0x%x\n", sr);
> + return IRQ_NONE;
> + }
> +
> if (flags & SAI_XIMR_OVRUDRIE) {
> dev_err(&pdev->dev, "IRQ %s\n",
> STM_SAI_IS_PLAYBACK(sai) ? "underrun" : "overrun");
> @@ -227,9 +231,9 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
> }
>
> if (status != SNDRV_PCM_STATE_RUNNING) {
> - snd_pcm_stream_lock(substream);
> - snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
> - snd_pcm_stream_unlock(substream);
> + snd_pcm_stream_lock(sai->substream);
> + snd_pcm_stop(sai->substream, SNDRV_PCM_STATE_XRUN);
> + snd_pcm_stream_unlock(sai->substream);
Actually changing to sai->substream opens a race, so this chunk is a
bad move, at least. We have no protection of sai->substream in this
context, thus it can hit a NULL dereference...
thanks,
Takashi
next prev parent reply other threads:[~2017-10-26 15:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 13:03 [INTERNAL][PATCH 0/7] ASoC: stm32: Add SAI synchronization support Olivier Moysan
2017-10-19 13:03 ` [INTERNAL][PATCH 1/7] ASoC: stm32: Add synchronization to SAI bindings Olivier Moysan
2017-10-21 10:31 ` Applied "ASoC: stm32: Add synchronization to SAI bindings" to the asoc tree Mark Brown
2017-10-19 13:03 ` [INTERNAL][PATCH 2/7] ASoC: stm32: sai: Move static settings to DAI init Olivier Moysan
2017-10-19 13:03 ` [INTERNAL][PATCH 3/7] ASoC: stm32: sai: Fix DMA burst size Olivier Moysan
2017-10-19 13:03 ` [INTERNAL][PATCH 4/7] ASoC: stm32: sai: fix stop management in isr Olivier Moysan
2017-10-21 10:16 ` Mark Brown
2017-10-21 10:32 ` Applied "ASoC: stm32: sai: fix stop management in isr" to the asoc tree Mark Brown
2017-10-26 15:32 ` Takashi Iwai [this message]
2017-11-02 16:38 ` [INTERNAL][PATCH 4/7] ASoC: stm32: sai: fix stop management in isr Olivier MOYSAN
2017-10-19 13:03 ` [INTERNAL][PATCH 5/7] ASoC: stm32: sai: Remove spurious IRQs on stop Olivier Moysan
2017-10-21 10:31 ` Applied "ASoC: stm32: sai: Remove spurious IRQs on stop" to the asoc tree Mark Brown
2017-10-19 13:03 ` [INTERNAL][PATCH 6/7] ASoC: stm32: sai: Fix get reset controller Olivier Moysan
2017-10-21 10:32 ` Applied "ASoC: stm32: sai: Fix get reset controller" to the asoc tree Mark Brown
2017-10-19 13:03 ` [INTERNAL][PATCH 7/7] ASoC: stm32: sai: Add synchronization support Olivier Moysan
2017-10-21 10:31 ` Applied "ASoC: stm32: sai: Add synchronization support" to the asoc tree Mark Brown
2017-10-19 13:27 ` [INTERNAL][PATCH 0/7] ASoC: stm32: Add SAI synchronization support Olivier MOYSAN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hmv4ekjr4.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alexandre.torgue@st.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnaud.pouliquen@st.com \
--cc=benjamin.gaignard@st.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kernel@stlinux.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=olivier.moysan@st.com \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®