From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26A6F341043; Fri, 21 Nov 2025 13:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763731755; cv=none; b=RLC2au7DSTQ1DhRrOfAFEztECo5mM5/dTSJHBUw/dfxi9qyRt1vhtk4MiykYdGh7X31qrSHeya1afO5z3j7iIbBbi417C74EgbwXSY3YV826XMY5PiMBbSfRBhuVrRjZgn+VN7AtTDR0jeXTjhb6Omdf4RCjJ3WIU/BeuCkwRO4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763731755; c=relaxed/simple; bh=rAbsr2BJD4DzhpiIJsfgAT+a5k+ic7cZxMRYTP7a2o0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ct1pu2U2uDZxq1ASdiwZZoZbsVEmWSZEvt+DuxlP6A6+b6JTc7isPDj/64I9eg6EiQPqKjHF7hSZjF1FeRiuMQl9C9JeKmC7/q7Bp1GZCvFBBSh8L7Le7dGUwl6R+EMZc3eEt/YlTWKLhLomucXqUm60dzVZiyxxTW5+r3cNRJI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qfcExzeH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qfcExzeH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EFA6C4CEF1; Fri, 21 Nov 2025 13:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1763731755; bh=rAbsr2BJD4DzhpiIJsfgAT+a5k+ic7cZxMRYTP7a2o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfcExzeHG7PvWm4YQSiXHzM9HI9Fg2SGlJXLC1sD902xalz6xyv8X3WwbE5ORuNr3 JdMGPRNTUT0YZ1o6T4s6as98VJDtOjIlKYUQi4CEUc1tHB72X26/Wx4tOVNwYjI22Y QlSdt2ckrP8/BeGfTGOjDnsXq1T9aPH0kk0JAK6Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haotian Zhang , Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 6.12 069/185] ASoC: cs4271: Fix regulator leak on probe failure Date: Fri, 21 Nov 2025 14:11:36 +0100 Message-ID: <20251121130146.364398911@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121130143.857798067@linuxfoundation.org> References: <20251121130143.857798067@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haotian Zhang [ Upstream commit 6b6eddc63ce871897d3a5bc4f8f593e698aef104 ] The probe function enables regulators at the beginning but fails to disable them in its error handling path. If any operation after enabling the regulators fails, the probe will exit with an error, leaving the regulators permanently enabled, which could lead to a resource leak. Add a proper error handling path to call regulator_bulk_disable() before returning an error. Fixes: 9a397f473657 ("ASoC: cs4271: add regulator consumer support") Signed-off-by: Haotian Zhang Reviewed-by: Charles Keepax Link: https://patch.msgid.link/20251105062246.1955-1-vulab@iscas.ac.cn Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/cs4271.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index e864188ae5eb9..1d3261d0f1fd0 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -581,17 +581,17 @@ static int cs4271_component_probe(struct snd_soc_component *component) ret = regcache_sync(cs4271->regmap); if (ret < 0) - return ret; + goto err_disable_regulator; ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2, CS4271_MODE2_PDN | CS4271_MODE2_CPEN, CS4271_MODE2_PDN | CS4271_MODE2_CPEN); if (ret < 0) - return ret; + goto err_disable_regulator; ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2, CS4271_MODE2_PDN, 0); if (ret < 0) - return ret; + goto err_disable_regulator; /* Power-up sequence requires 85 uS */ udelay(85); @@ -601,6 +601,10 @@ static int cs4271_component_probe(struct snd_soc_component *component) CS4271_MODE2_MUTECAEQUB); return 0; + +err_disable_regulator: + regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); + return ret; } static void cs4271_component_remove(struct snd_soc_component *component) -- 2.51.0