pcm: Fix the wrong PCM object passed for locking/unlocking
Most of PCM API functions have snd_pcm_lock()/unlock() wraps for the
actual calls of ops, and some plugins try to unlock/relock internally
for the given PCM object. This, unfortunately, causes a problem in
some configurations and leads to the unexpected behavior or deadlock.
The main problem is that we call snd_pcm_lock() with the given PCM
object, while calling the ops with pcm->op_arg or pcm->fast_op_arg as
the slave PCM object. Meanwhile the plugin code assumes that the
passed PCM object is already locked, and calls snd_pcm_unlock().
This bug doesn't hit always because in most cases pcm->op_arg and
fast_op_arg are identical with pcm itself. But in some configurations
they have different values, so the problem surfaces.
This patch is an attempt to resolve these inconsistencies. It
replaces most of snd_pcm_lock()/unlock() calls with either pcm->op_arg
or pcm->fast_op_arg, depending on the call pattern, so that the plugin
code can safely run snd_pcm_unlock() to the given PCM object.
Fixes: 54931e5a5455 ("pcm: Add thread-safety to PCM API") Reported-by: Ben Russell <thematrixeatsyou@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>