]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
ALSA: core: Fix double-free at snd_card_new()
authorTakashi Iwai <tiwai@suse.de>
Mon, 19 Sep 2022 12:35:16 +0000 (14:35 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 23 Nov 2022 14:11:35 +0000 (15:11 +0100)
commitc4e5f6d74852be5f57e9ece265237dc6be2c2469
tree2376f43819114a0a296fac58bb856b7f0b70b550
parent2c6bed8679153c7464695a3f22d6e67cc9b8f7dc
ALSA: core: Fix double-free at snd_card_new()

BugLink: https://bugs.launchpad.net/bugs/1995420
commit c3afa2a402d1ecefa59f88d55d9e765f52f75bd9 upstream.

During the code change to add the support for devres-managed card
instance, we put an explicit kfree(card) call at the error path in
snd_card_new().  This is needed for the early error path before the
card is initialized with the device, but is rather superfluous and
causes a double-free at the error path after the card instance is
initialized, as the destructor of the card object already contains a
kfree() call.

This patch fixes the double-free situation by removing the superfluous
kfree().  Meanwhile we need to call kfree() explicitly for the early
error path, so it's added there instead.

Fixes: e8ad415b7a55 ("ALSA: core: Add managed card creation")
Reported-by: Rondreis <linhaoguo86@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/CAB7eexL1zBnB636hwS27d-LdPYZ_R1-5fJS_h=ZbCWYU=UPWJg@mail.gmail.com
Link: https://lore.kernel.org/r/20220919123516.28222-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
sound/core/init.c