Skip to content

Commit 528763f

Browse files
CassivsGabriellisgregkh
authored andcommitted
ALSA: pcmtest: Fix resource leaks in module init error paths
commit d5d5f80 upstream. pcmtest allocates its pattern buffers and creates its debugfs tree before registering the platform device and driver, but mod_init() does not release those resources when a later init step fails. As a result, a debugfs directory creation failure leaks the pattern buffers, while platform_device_register() and platform_driver_register() failures leave both the pattern buffers and the debugfs tree behind. The recent fix for failed device registration only dropped the embedded device reference. Add the missing cleanup for the debugfs tree and pattern buffers in the remaining module init error paths. Fixes: 315a3d5 ("ALSA: Implement the new Virtual PCM Test Driver") Cc: stable@vger.kernel.org Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> Link: https://patch.msgid.link/20260421-alsa-pcmtest-init-unwind-v1-1-03fe0c423dbb@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c21ef73 commit 528763f

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

sound/drivers/pcmtest.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,24 @@ static int __init mod_init(void)
753753

754754
err = init_debug_files(buf_allocated);
755755
if (err)
756-
return err;
756+
goto err_free_patterns;
757757
err = platform_device_register(&pcmtst_pdev);
758758
if (err) {
759759
platform_device_put(&pcmtst_pdev);
760-
return err;
760+
goto err_clear_debug;
761761
}
762762
err = platform_driver_register(&pcmtst_pdrv);
763-
if (err)
763+
if (err) {
764764
platform_device_unregister(&pcmtst_pdev);
765+
goto err_clear_debug;
766+
}
767+
768+
return 0;
769+
770+
err_clear_debug:
771+
clear_debug_files();
772+
err_free_patterns:
773+
free_pattern_buffers();
765774
return err;
766775
}
767776

0 commit comments

Comments
 (0)