V4L/DVB (8026): Avoids an OOPS if dev struct can't be successfully recovered

On some alsa versions, it seems that snd_pcm_substream_chip(substream)
is returning a NULL pointer. This causes an OOPS, as reported by:

https://bugs.launchpad.net/ubuntu/+source/linux-ubuntu-modules-2.6.24/+bug/212271
https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/212960

This patch avoids the OOPS by not letting and open() succeed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
Mauro Carvalho Chehab 2008-06-14 09:41:18 -03:00
Родитель 913f5fc209
Коммит 83ee87a31d
3 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -332,6 +332,12 @@ static int snd_cx88_pcm_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
int err; int err;
if (!chip) {
printk(KERN_ERR "BUG: cx88 can't find device struct."
" Can't proceed with open\n");
return -ENODEV;
}
err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS); err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS);
if (err < 0) if (err < 0)
goto _error; goto _error;

Просмотреть файл

@ -268,6 +268,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
dprintk("opening device and trying to acquire exclusive lock\n"); dprintk("opening device and trying to acquire exclusive lock\n");
if (!dev) {
printk(KERN_ERR "BUG: em28xx can't find device struct."
" Can't proceed with open\n");
return -ENODEV;
}
/* Sets volume, mute, etc */ /* Sets volume, mute, etc */
dev->mute = 0; dev->mute = 0;

Просмотреть файл

@ -613,9 +613,15 @@ static int snd_card_saa7134_capture_open(struct snd_pcm_substream * substream)
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
snd_card_saa7134_pcm_t *pcm; snd_card_saa7134_pcm_t *pcm;
snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
struct saa7134_dev *dev = saa7134->dev; struct saa7134_dev *dev;
int amux, err; int amux, err;
if (!saa7134) {
printk(KERN_ERR "BUG: saa7134 can't find device struct."
" Can't proceed with open\n");
return -ENODEV;
}
dev = saa7134->dev;
mutex_lock(&dev->dmasound.lock); mutex_lock(&dev->dmasound.lock);
dev->dmasound.read_count = 0; dev->dmasound.read_count = 0;