From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794590658; b=YaH7/3QA4jS8wlRqJWn2oJR+BZ1rr3RQuC+zzJ5tTmPRTsfA4WrEEWbOBgIsPCDET2qm B6FNXmq/CHuVeUoJklBgp8D57U/19fejmK9JT4q83u11ybMpWrw7JY+3WsQpsQECe9NEx A9f+IA3gaQcb6R6bywqa+TM5+XO4BhZBWwsPQG+wc7tOGsLm9Z5fF8HK519LyU6JLaWCW uDQkBo70zgEbaC0Sr+TwliCkKAEjq2hHwh+HdBUlxZ+wggYlbBofhPyiZe+mrEAYy/IAa LgC4Wctp8hQ0WTrLLlq01XYisPCeGwXvTplX7nVCYI5awX+/HQMweA0+9m2hAobABRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794590658; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=yoFnJHr+fo83rJbdM2dt+cKkDhQtgpZoGr7d1TPpJWI=; b=jbxSqbqndsbceCt44i/cI0QP5o4pw129bcE9eKx7RZV3J2ZXTtKVZbU5Nak1QYfJl1FC 8Fq2G8GS8uavlH/qlhpzl2Te7ztza6yytgJRAVxCZPxHg9faSVgRJColJ4dw0gv6YEJHh DOxhh9CRWQEn6In/nqJxEhMT+csFabIkS0LkkCsqxM85u/nZk+wN9r1bM6TRxoIVSZ+Yx PmZges17GR26CkLt3BFj5l/CXbxUmTJOCwETdFURDDPaVMBFQ4nnu2ujA4zaOIL+rIHXw ORGrbzoFiE3XMCZmB3k/HYVBFD9QqNzGWN3O2R3lwHQR4/WCKmNjautofCjlpVGF0Ww== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=POCmirI+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40E7A60776CE; Fri, 13 Nov 2026 17:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=POCmirI+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id E12ED1F000C7; Fri, 13 Nov 2026 17:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794590658; bh=yoFnJHr+fo83rJbdM2dt+cKkDhQtgpZoGr7d1TPpJWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=POCmirI+yswj+8Jmh+P/ui8s9HgOQ1wXNkV2ZVCVf223gg8VxoWSQAmkAHPHEX7OR +SfERSagy216jIHDUCWgZTDGv1yU9ngVmVblgXa0xZI4W+rV/lRi/DFXHI2Wh80pbP 064/MG+1K3FUawQ88JKs2YAI2LThgIoMxEh4zdpo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ma Ke , Takashi Iwai , Sasha Levin Subject: [PATCH 6.18 576/686] ALSA: hda: cs35l41: Fix ACPI device reference leak on probe failure Date: Fri, 13 Nov 2026 10:51:49 -0500 Message-ID: <20261113153841.175970594@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153820.902362109@linuxfoundation.org> References: <20261113153820.902362109@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ma Ke [ Upstream commit 8d70e364e866bdfca81eee24d0688fac9472cfb9 ] cs35l41_hda_probe() takes an acpi_device through cs35l41_hda_read_acpi() and stores it in cs35l41->dacpi. Only the failures that happen later reach the err: label, which is where that reference and cs35l41->acpi_subsystem_id are released, so the early return taken when cs35l41_hda_read_acpi() fails leaves both behind. Keep the ownership in the caller instead of dropping the reference inside cs35l41_hda_read_acpi(). That removes the need to work out whether a given failure path has already released it, and with it the double put that cs35l41_hda_parse_acpi() would otherwise cause when it fails after having released the device itself. cs35l41_hda_parse_acpi() and the !physdev path no longer put the reference, and the early failure enters the existing err: cleanup tail through a new err_acpi label. The label sits between the reset of the codec and the gpio cleanup, so an early failure also releases the reset and chip-select descriptors that cs35l41_hda_parse_acpi() may already have taken, while still skipping cs35l41_safe_reset() on a codec that was never brought up. cs35l41->dacpi comes from devm_kzalloc() and is only assigned once the ACPI device has been found, so the put is a no-op when the lookup itself failed. Found by code review. Fixes: 447106e92a0c ("ALSA: hda: cs35l41: Support mute notifications for CS35L41 HDA") Cc: stable@vger.kernel.org Signed-off-by: Ma Ke Link: https://patch.msgid.link/20261012084152.3740340-1-make_ruc2021@163.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/hda/codecs/side-codecs/cs35l41_hda.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/hda/codecs/side-codecs/cs35l41_hda.c b/sound/hda/codecs/side-codecs/cs35l41_hda.c index a7fc4ba35e3a1..d9f687967be51 100644 --- a/sound/hda/codecs/side-codecs/cs35l41_hda.c +++ b/sound/hda/codecs/side-codecs/cs35l41_hda.c @@ -1921,7 +1921,6 @@ int cs35l41_hda_parse_acpi(struct cs35l41_hda *cs35l41, struct device *physdev, hw_cfg->valid = false; hw_cfg->gpio1.valid = false; hw_cfg->gpio2.valid = false; - acpi_dev_put(cs35l41->dacpi); return ret; } @@ -1942,10 +1941,8 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i cs35l41->dacpi = adev; struct device *physdev __free(put_device) = get_device(acpi_get_first_physical_node(adev)); - if (!physdev) { - acpi_dev_put(adev); + if (!physdev) return -ENODEV; - } sub = acpi_get_subsystem_id(ACPI_HANDLE(physdev)); if (IS_ERR(sub)) @@ -2000,8 +1997,10 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i dev_set_drvdata(dev, cs35l41); ret = cs35l41_hda_read_acpi(cs35l41, device_name, id); - if (ret) - return dev_err_probe(cs35l41->dev, ret, "Platform not supported\n"); + if (ret) { + dev_err_probe(cs35l41->dev, ret, "Platform not supported\n"); + goto err_acpi; + } if (IS_ERR(cs35l41->reset_gpio)) { ret = PTR_ERR(cs35l41->reset_gpio); @@ -2088,6 +2087,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i err: if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); +err_acpi: gpiod_put(cs35l41->reset_gpio); gpiod_put(cs35l41->cs_gpio); acpi_dev_put(cs35l41->dacpi); -- 2.53.0