ALSA: snd-usb-us122l: Fix missing NULL checks
Fix missing NULL checks in usb_stream_hwdep_poll() and usb_stream_hwdep_ioctl(). Wake up poll waiters before returning from usb_stream_hwdep_ioctl(). Signed-off-by: Karsten Wiese <fzu@wemgehoertderstaat.de> Cc: stable@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
921eebdc18
commit
cdce2db74e
1 changed files with 20 additions and 21 deletions
|
@ -273,29 +273,26 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw,
|
||||||
struct file *file, poll_table *wait)
|
struct file *file, poll_table *wait)
|
||||||
{
|
{
|
||||||
struct us122l *us122l = hw->private_data;
|
struct us122l *us122l = hw->private_data;
|
||||||
struct usb_stream *s = us122l->sk.s;
|
|
||||||
unsigned *polled;
|
unsigned *polled;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
poll_wait(file, &us122l->sk.sleep, wait);
|
poll_wait(file, &us122l->sk.sleep, wait);
|
||||||
|
|
||||||
switch (s->state) {
|
mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR;
|
||||||
case usb_stream_ready:
|
if (mutex_trylock(&us122l->mutex)) {
|
||||||
if (us122l->first == file)
|
struct usb_stream *s = us122l->sk.s;
|
||||||
polled = &s->periods_polled;
|
if (s && s->state == usb_stream_ready) {
|
||||||
else
|
if (us122l->first == file)
|
||||||
polled = &us122l->second_periods_polled;
|
polled = &s->periods_polled;
|
||||||
if (*polled != s->periods_done) {
|
else
|
||||||
*polled = s->periods_done;
|
polled = &us122l->second_periods_polled;
|
||||||
mask = POLLIN | POLLOUT | POLLWRNORM;
|
if (*polled != s->periods_done) {
|
||||||
break;
|
*polled = s->periods_done;
|
||||||
|
mask = POLLIN | POLLOUT | POLLWRNORM;
|
||||||
|
} else
|
||||||
|
mask = 0;
|
||||||
}
|
}
|
||||||
/* Fall through */
|
mutex_unlock(&us122l->mutex);
|
||||||
mask = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
@ -381,6 +378,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
|
||||||
{
|
{
|
||||||
struct usb_stream_config *cfg;
|
struct usb_stream_config *cfg;
|
||||||
struct us122l *us122l = hw->private_data;
|
struct us122l *us122l = hw->private_data;
|
||||||
|
struct usb_stream *s;
|
||||||
unsigned min_period_frames;
|
unsigned min_period_frames;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
bool high_speed;
|
bool high_speed;
|
||||||
|
@ -426,18 +424,18 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
|
||||||
snd_power_wait(hw->card, SNDRV_CTL_POWER_D0);
|
snd_power_wait(hw->card, SNDRV_CTL_POWER_D0);
|
||||||
|
|
||||||
mutex_lock(&us122l->mutex);
|
mutex_lock(&us122l->mutex);
|
||||||
|
s = us122l->sk.s;
|
||||||
if (!us122l->master)
|
if (!us122l->master)
|
||||||
us122l->master = file;
|
us122l->master = file;
|
||||||
else if (us122l->master != file) {
|
else if (us122l->master != file) {
|
||||||
if (memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg))) {
|
if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg))) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
us122l->slave = file;
|
us122l->slave = file;
|
||||||
}
|
}
|
||||||
if (!us122l->sk.s ||
|
if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg)) ||
|
||||||
memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg)) ||
|
s->state == usb_stream_xrun) {
|
||||||
us122l->sk.s->state == usb_stream_xrun) {
|
|
||||||
us122l_stop(us122l);
|
us122l_stop(us122l);
|
||||||
if (!us122l_start(us122l, cfg->sample_rate, cfg->period_frames))
|
if (!us122l_start(us122l, cfg->sample_rate, cfg->period_frames))
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
|
@ -448,6 +446,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
|
||||||
mutex_unlock(&us122l->mutex);
|
mutex_unlock(&us122l->mutex);
|
||||||
free:
|
free:
|
||||||
kfree(cfg);
|
kfree(cfg);
|
||||||
|
wake_up_all(&us122l->sk.sleep);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue