FAILED: patch "[PATCH] ALSA: ac97: fix a double free in" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 830988b6cf197e6dcffdfe2008c5738e6c6c3c0f
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026011239-handled-worried-ca90@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 830988b6cf197e6dcffdfe2008c5738e6c6c3c0f Mon Sep 17 00:00:00 2001
From: Haoxiang Li <[email protected]>
Date: Sat, 20 Dec 2025 00:28:45 +0800
Subject: [PATCH] ALSA: ac97: fix a double free in
snd_ac97_controller_register()
If ac97_add_adapter() fails, put_device() is the correct way to drop the device reference. kfree() is not required.
Add kfree() if idr_alloc() fails and in ac97_adapter_release() to do the cleanup.
Found by code review.
sound/ac97/bus.c +5 -5
@@ -298,6 +298,7 @@ static void ac97_adapter_release(struct device *dev)idr_remove (&ac97_adapter_idr, ac97_ctrl->nr);dev_dbg (&ac97_ctrl->adap,"adapter unregistered by %s\n" ,dev_name (ac97_ctrl->parent)); +kfree (ac97_ctrl); }static const struct device_type ac97_adapter_type = {
@@ -319,7 +320,9 @@ static int ac97_add_adapter(struct ac97_controller *ac97_ctrl) ret =device_register (&ac97_ctrl->adap);if (ret)put_device (&ac97_ctrl->adap); - } + }else +kfree (ac97_ctrl); +if (!ret) {list_add (&ac97_ctrl->controllers, &ac97_controllers); dev_dbg(&ac97_ctrl->adap, "adapter registered by %s\n",
@@ -361,14 +364,11 @@ struct ac97_controller *snd_ac97_controller_register( ret =ac97_add_adapter (ac97_ctrl);if (ret) - goto err; +return ERR_PTR (ret);ac97_bus_reset (ac97_ctrl);ac97_bus_scan (ac97_ctrl);return ac97_ctrl; -err: -kfree (ac97_ctrl); -return ERR_PTR (ret); }EXPORT_SYMBOL_GPL (snd_ac97_controller_register);