[media] ivtv: Fix a sleep-in-atomic bug in snd_ivtv_pcm_hw_free
The driver may sleep under a spin lock, and the function call path is: snd_ivtv_pcm_hw_free (acquire the lock by spin_lock_irqsave) vfree --> may sleep To fix it, the "substream->runtime->dma_area" is passed to a temporary value, and mark it NULL when holding the lock. The memory is freed by vfree through the temporary value outside the lock holding. Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com> [hans.verkuil@cisco.com: removed unnecessary 'if (dma_area)'] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
parent
dde32d4134
commit
d989dc20c5
|
@ -262,14 +262,16 @@ static int snd_ivtv_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_ivtv_card *itvsc = snd_pcm_substream_chip(substream);
|
struct snd_ivtv_card *itvsc = snd_pcm_substream_chip(substream);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
unsigned char *dma_area = NULL;
|
||||||
|
|
||||||
spin_lock_irqsave(&itvsc->slock, flags);
|
spin_lock_irqsave(&itvsc->slock, flags);
|
||||||
if (substream->runtime->dma_area) {
|
if (substream->runtime->dma_area) {
|
||||||
dprintk("freeing pcm capture region\n");
|
dprintk("freeing pcm capture region\n");
|
||||||
vfree(substream->runtime->dma_area);
|
dma_area = substream->runtime->dma_area;
|
||||||
substream->runtime->dma_area = NULL;
|
substream->runtime->dma_area = NULL;
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&itvsc->slock, flags);
|
spin_unlock_irqrestore(&itvsc->slock, flags);
|
||||||
|
vfree(dma_area);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue