[alsa-devel] [PATCH] 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 --- sound/usb/usx2y/us122l.c | 41 ++++++++++++++++++++--------------------- 1 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 91bb296..7abda8d 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -269,29 +269,26 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) { struct us122l *us122l = hw->private_data; - struct usb_stream *s = us122l->sk.s; unsigned *polled; unsigned int mask;
poll_wait(file, &us122l->sk.sleep, wait);
- switch (s->state) { - case usb_stream_ready: - if (us122l->first == file) - polled = &s->periods_polled; - else - polled = &us122l->second_periods_polled; - if (*polled != s->periods_done) { - *polled = s->periods_done; - mask = POLLIN | POLLOUT | POLLWRNORM; - break; + mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR; + if (mutex_trylock(&us122l->mutex)) { + struct usb_stream *s = us122l->sk.s; + if (s && s->state == usb_stream_ready) { + if (us122l->first == file) + polled = &s->periods_polled; + else + polled = &us122l->second_periods_polled; + if (*polled != s->periods_done) { + *polled = s->periods_done; + mask = POLLIN | POLLOUT | POLLWRNORM; + } else + mask = 0; } - /* Fall through */ - mask = 0; - break; - default: - mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR; - break; + mutex_unlock(&us122l->mutex); } return mask; } @@ -377,6 +374,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, { struct usb_stream_config *cfg; struct us122l *us122l = hw->private_data; + struct usb_stream *s; unsigned min_period_frames; int err = 0; bool high_speed; @@ -422,18 +420,18 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, snd_power_wait(hw->card, SNDRV_CTL_POWER_D0);
mutex_lock(&us122l->mutex); + s = us122l->sk.s; if (!us122l->master) 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; goto unlock; } us122l->slave = file; } - if (!us122l->sk.s || - memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg)) || - us122l->sk.s->state == usb_stream_xrun) { + if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg)) || + s->state == usb_stream_xrun) { us122l_stop(us122l); if (!us122l_start(us122l, cfg->sample_rate, cfg->period_frames)) err = -EIO; @@ -444,6 +442,7 @@ unlock: mutex_unlock(&us122l->mutex); free: kfree(cfg); + wake_up_all(&us122l->sk.sleep); return err; }
At Tue, 4 Jan 2011 01:20:37 +0100, Karsten Wiese wrote:
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
Applied. Thanks.
Takashi
sound/usb/usx2y/us122l.c | 41 ++++++++++++++++++++--------------------- 1 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 91bb296..7abda8d 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -269,29 +269,26 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) { struct us122l *us122l = hw->private_data;
struct usb_stream *s = us122l->sk.s; unsigned *polled; unsigned int mask;
poll_wait(file, &us122l->sk.sleep, wait);
switch (s->state) {
case usb_stream_ready:
if (us122l->first == file)
polled = &s->periods_polled;
else
polled = &us122l->second_periods_polled;
if (*polled != s->periods_done) {
*polled = s->periods_done;
mask = POLLIN | POLLOUT | POLLWRNORM;
break;
- mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR;
- if (mutex_trylock(&us122l->mutex)) {
struct usb_stream *s = us122l->sk.s;
if (s && s->state == usb_stream_ready) {
if (us122l->first == file)
polled = &s->periods_polled;
else
polled = &us122l->second_periods_polled;
if (*polled != s->periods_done) {
*polled = s->periods_done;
mask = POLLIN | POLLOUT | POLLWRNORM;
} else
}mask = 0;
/* Fall through */
mask = 0;
break;
- default:
mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR;
break;
} return mask;mutex_unlock(&us122l->mutex);
} @@ -377,6 +374,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, { struct usb_stream_config *cfg; struct us122l *us122l = hw->private_data;
- struct usb_stream *s; unsigned min_period_frames; int err = 0; bool high_speed;
@@ -422,18 +420,18 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, snd_power_wait(hw->card, SNDRV_CTL_POWER_D0);
mutex_lock(&us122l->mutex);
- s = us122l->sk.s; if (!us122l->master) us122l->master = file; else if (us122l->master != file) {
if (memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg))) {
} us122l->slave = file; }if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg))) { err = -EIO; goto unlock;
- if (!us122l->sk.s ||
memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg)) ||
us122l->sk.s->state == usb_stream_xrun) {
- if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg)) ||
us122l_stop(us122l); if (!us122l_start(us122l, cfg->sample_rate, cfg->period_frames)) err = -EIO;s->state == usb_stream_xrun) {
@@ -444,6 +442,7 @@ unlock: mutex_unlock(&us122l->mutex); free: kfree(cfg);
- wake_up_all(&us122l->sk.sleep); return err;
}
-- 1.7.2.3
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
They are not needed here.
Signed-off-by: Karsten Wiese fzu@wemgehoertderstaat.de Cc: stable@kernel.org ---
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c index 12ae034..dafcf79 100644 --- a/sound/usb/usx2y/usb_stream.c +++ b/sound/usb/usx2y/usb_stream.c @@ -673,7 +673,7 @@ dotry: inurb->transfer_buffer_length = inurb->number_of_packets * inurb->iso_frame_desc[0].length; - preempt_disable(); + if (u == 0) { int now; struct usb_device *dev = inurb->dev; @@ -685,19 +685,17 @@ dotry: } err = usb_submit_urb(inurb, GFP_ATOMIC); if (err < 0) { - preempt_enable(); snd_printk(KERN_ERR"usb_submit_urb(sk->inurb[%i])" " returned %i\n", u, err); return err; } err = usb_submit_urb(outurb, GFP_ATOMIC); if (err < 0) { - preempt_enable(); snd_printk(KERN_ERR"usb_submit_urb(sk->outurb[%i])" " returned %i\n", u, err); return err; } - preempt_enable(); + if (inurb->start_frame != outurb->start_frame) { snd_printd(KERN_DEBUG "u[%i] start_frames differ in:%u out:%u\n",
At Fri, 30 Dec 2011 01:42:01 +0100, Karsten Wiese wrote:
They are not needed here.
Signed-off-by: Karsten Wiese fzu@wemgehoertderstaat.de Cc: stable@kernel.org
Applied now. Thanks.
Takashi
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c index 12ae034..dafcf79 100644 --- a/sound/usb/usx2y/usb_stream.c +++ b/sound/usb/usx2y/usb_stream.c @@ -673,7 +673,7 @@ dotry: inurb->transfer_buffer_length = inurb->number_of_packets * inurb->iso_frame_desc[0].length;
preempt_disable();
- if (u == 0) { int now; struct usb_device *dev = inurb->dev;
@@ -685,19 +685,17 @@ dotry: } err = usb_submit_urb(inurb, GFP_ATOMIC); if (err < 0) {
} err = usb_submit_urb(outurb, GFP_ATOMIC); if (err < 0) {preempt_enable(); snd_printk(KERN_ERR"usb_submit_urb(sk->inurb[%i])" " returned %i\n", u, err); return err;
}preempt_enable(); snd_printk(KERN_ERR"usb_submit_urb(sk->outurb[%i])" " returned %i\n", u, err); return err;
preempt_enable();
- if (inurb->start_frame != outurb->start_frame) { snd_printd(KERN_DEBUG "u[%i] start_frames differ in:%u out:%u\n",
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Use $DEVNAME instead of $DEVICE in script tascam_fw.
Signed-off-by: Karsten Wiese fzuuzf@googlemail.com --- usx2yloader/tascam_fw.in | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/usx2yloader/tascam_fw.in b/usx2yloader/tascam_fw.in index 14bbc6c..d3145e3 100644 --- a/usx2yloader/tascam_fw.in +++ b/usx2yloader/tascam_fw.in @@ -53,8 +53,8 @@ if [ ! -x $LOADER ]; then fi
if [ -x /usr/bin/logger ]; then - /usr/bin/logger -t $0 "load $FIRMWARE for $PRODUCT to $DEVICE" + /usr/bin/logger -t $0 "load $FIRMWARE for $PRODUCT to $DEVNAME" fi -$LOADER $FLAGS -s $LOADERFIRMWARE -I $FIRMWARE +$LOADER $FLAGS -s $LOADERFIRMWARE -I $FIRMWARE -D $DEVNAME
exit 0
At Wed, 25 Apr 2012 12:25:04 +0200, Karsten Wiese wrote:
Use $DEVNAME instead of $DEVICE in script tascam_fw.
Signed-off-by: Karsten Wiese fzuuzf@googlemail.com
Applied now. Thanks.
Takashi
usx2yloader/tascam_fw.in | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/usx2yloader/tascam_fw.in b/usx2yloader/tascam_fw.in index 14bbc6c..d3145e3 100644 --- a/usx2yloader/tascam_fw.in +++ b/usx2yloader/tascam_fw.in @@ -53,8 +53,8 @@ if [ ! -x $LOADER ]; then fi
if [ -x /usr/bin/logger ]; then
- /usr/bin/logger -t $0 "load $FIRMWARE for $PRODUCT to $DEVICE"
- /usr/bin/logger -t $0 "load $FIRMWARE for $PRODUCT to $DEVNAME"
fi -$LOADER $FLAGS -s $LOADERFIRMWARE -I $FIRMWARE +$LOADER $FLAGS -s $LOADERFIRMWARE -I $FIRMWARE -D $DEVNAME
exit 0
1.7.7.6
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
participants (2)
-
Karsten Wiese
-
Takashi Iwai