• Takashi Iwai's avatar
    ALSA: pcm: Fix refcount_inc() on zero usage · 0e279dce
    Takashi Iwai authored
    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: f57f3df0 ("ALSA: pcm: More fine-grained PCM link locking")
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204221Reported-and-tested-by: default avatarDuncan Overbruck <kernel@duncano.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    0e279dce
pcm_native.c 102 KB