• Takashi Iwai's avatar
    ALSA: usx2y: Fix potential memory leaks · 02d382af
    Takashi Iwai authored
    Theoretically the initialization functions in usx2y drivers may be
    called multiple times as the driver gets initialized via hwpdep
    ioctl.  Meanwhile, those functions including memory allocations don't
    check whether they are called twice, and they forget the old
    resources, which would lead to memory leaks.
    
    This patch adds the sanity checks about the doubly initializations to
    give kernel WARNING, and returns an error in such a case.  Also, each
    allocation assures to release the resources at its error path
    properly.
    
    Link: https://lore.kernel.org/r/20210517131545.27252-7-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    02d382af
usbusx2y.c 13.1 KB