]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ALSA: pcmtest: fix reference leak on failed device registration
authorGuangshuo Li <lgs201920130244@gmail.com>
Wed, 15 Apr 2026 19:31:38 +0000 (03:31 +0800)
committerTakashi Iwai <tiwai@suse.de>
Fri, 17 Apr 2026 07:54:34 +0000 (09:54 +0200)
commit4ff036f95238f02c87e5d7c0a9d93748582a8950
treea5d995bb02ab5b16cde8afb446d2d28adda5e78e
parentdc88eef8f55e85e92d016cdf7e291f5560efd79b
ALSA: pcmtest: fix reference leak on failed device registration

When platform_device_register() fails in mod_init(), the embedded struct
device in pcmtst_pdev has already been initialized by
device_initialize(), but the failure path returns the error without
dropping the device reference for the current platform device:

  mod_init()
    -> platform_device_register(&pcmtst_pdev)
       -> device_initialize(&pcmtst_pdev.dev)
       -> setup_pdev_dma_masks(&pcmtst_pdev)
       -> platform_device_add(&pcmtst_pdev)

This leads to a reference leak when platform_device_register() fails.
Fix this by calling platform_device_put() before returning the error.

The issue was identified by a static analysis tool I developed and
confirmed by manual review.

Fixes: 315a3d57c64c5 ("ALSA: Implement the new Virtual PCM Test Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Link: https://patch.msgid.link/20260415193138.3861297-1-lgs201920130244@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/drivers/pcmtest.c