]> git.baikalelectronics.ru Git - kernel.git/commit
ALSA: pcm: Fix refcount_inc() on zero usage
authorTakashi Iwai <tiwai@suse.de>
Fri, 19 Jul 2019 08:55:05 +0000 (10:55 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 19 Jul 2019 13:47:00 +0000 (15:47 +0200)
commite855973381a3a29c5102a04a3fe7877764755920
tree404599ef22d243be51004f7252fc6188aa22f70c
parent177e948adac0f4d3133a51110c2384851afb20cb
ALSA: pcm: Fix refcount_inc() on zero usage

The recent rewrite of PCM link lock management introduced the refcount
in snd_pcm_group object, managed by the kernel refcount_t API.  This
caused unexpected kernel warnings when the kernel is built with
CONFIG_REFCOUNT_FULL=y.  As the warning line indicates, the problem is
obviously that we start with refcount=0 and do refcount_inc() for
adding each PCM link, while refcount_t API doesn't like refcount_inc()
performed on zero.

For adapting the proper refcount_t usage, this patch changes the logic
slightly:
- The initial refcount is 1, assuming the single list entry
- The refcount is incremented / decremented at each PCM link addition
  and deletion
- ... which allows us concentrating only on the refcount as a release
  condition

Fixes: 977d7609a592 ("ALSA: pcm: More fine-grained PCM link locking")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204221
Reported-and-tested-by: Duncan Overbruck <kernel@duncano.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_native.c