Skip to content

Commit

Permalink
ALSA: line6: Fix the error recovery in line6_pcm_acquire()
Browse files Browse the repository at this point in the history
line6_pcm_acquire() tries to restore the newly obtained resources at
the error path.  But some flags aren't recorded and released properly
when the corresponding buffer is already present.  These bits have to
be cleared in the error recovery, too.

Also, "flags_final" can be initialized to zero since we pass only the
subset of "channels" bits.

Tested-by: Chris Rorvick <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jan 28, 2015
1 parent 6aa7f8e commit 5343ecf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sound/usb/line6/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels)
flags_new = flags_old | channels;
} while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old);

flags_final = flags_old;
flags_final = 0;

line6pcm->prev_fbuf = NULL;

Expand All @@ -120,9 +120,9 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels)
err = -ENOMEM;
goto pcm_acquire_error;
}

flags_final |= channels & LINE6_BITS_CAPTURE_BUFFER;
}

flags_final |= channels & LINE6_BITS_CAPTURE_BUFFER;
}

if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_STREAM)) {
Expand Down Expand Up @@ -157,9 +157,9 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels)
err = -ENOMEM;
goto pcm_acquire_error;
}

flags_final |= channels & LINE6_BITS_PLAYBACK_BUFFER;
}

flags_final |= channels & LINE6_BITS_PLAYBACK_BUFFER;
}

if (test_flags(flags_old, flags_new, LINE6_BITS_PLAYBACK_STREAM)) {
Expand Down Expand Up @@ -187,7 +187,7 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels)
If not all requested resources/streams could be obtained, release
those which were successfully obtained (if any).
*/
line6_pcm_release(line6pcm, flags_final & channels);
line6_pcm_release(line6pcm, flags_final);
return err;
}
EXPORT_SYMBOL_GPL(line6_pcm_acquire);
Expand Down

0 comments on commit 5343ecf

Please sign in to comment.