From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 548B646EF9D; Tue, 21 Jul 2026 19:57:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663825; cv=none; b=HRXu3Rhno6KqDSqJy2VkZPO1hwF3FQW+HGD/dgYA+sdHddJ/PuRjq1CDjEee2PW55GO81BApcq1nRfEXa7PR0brIcvUvwUpJ1zw30NWDjHp4PBK0pQLpUYUbabrKz5eQUo3uxCwazWyBY1cEyrt+l1sLfbb2Q3DonykDPdmn36E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663825; c=relaxed/simple; bh=CoPBsxk2TvPWOLMi9dH34iCLbqwZ/D5iQK5uo+bernU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SM9DxpzaZffMI0QdJARM6fVp3fvMquYxwg7Rl+FCZV6Cy0svBeeRfoxW0CjvNoMMj8s0xj5SnGTmTmKM25aV0jL+KszwK9bBzsMj9dveHuFDKExyulQhr/ek+YHbRJMS4tqG6qVDr7l54E+jnboQiny6+031g0SQcPtQxDGXONk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IJT5RTdb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IJT5RTdb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9C691F000E9; Tue, 21 Jul 2026 19:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663824; bh=CumD5lFwpxQ0Ky30FR7r01egtt6Jzn5WSMQ68oxkwsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IJT5RTdbaLydcTgRjWXXJKvb4Q7JTkMDlCGS8Ti/rWOzF1gKKisfsn99mr1a+OZxl N8JjlkDU/KFMEQfJl9bIDoCGA5tw27Ft0+ZDTgj+hqva8POFcCkCw4xb8PTCuapprB rB4YeQqp8O4Srpk8fB5Y3YNBOAsMi3O0GVbDinp4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, WenTao Liang , Sebastian Reichel Subject: [PATCH 6.12 0926/1276] power: supply: charger-manager: fix refcount leak in is_full_charged() Date: Tue, 21 Jul 2026 17:22:49 +0200 Message-ID: <20260721152506.753920638@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev 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: WenTao Liang commit 4373cfa38ead58f980362c841b0d0bdf8c4d956c upstream. In is_full_charged(), power_supply_get_by_name() is called to obtain a reference to the fuel_gauge power supply. If the voltage check (uV >= desc->fullbatt_uV) succeeds, the function returns true directly without releasing the reference, leaking the refcount. Fix this by setting a flag and jumping to the out label where power_supply_put() properly drops the reference. Cc: stable@vger.kernel.org Fixes: e132fc6bb89b ("power: supply: charger-manager: Make decisions focussed on battery status") Signed-off-by: WenTao Liang Link: https://patch.msgid.link/20260611005322.53096-1-vulab@iscas.ac.cn Signed-off-by: Sebastian Reichel Signed-off-by: Greg Kroah-Hartman --- drivers/power/supply/charger-manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -302,8 +302,10 @@ static bool is_full_charged(struct charg if (cm->battery_status == POWER_SUPPLY_STATUS_FULL && desc->fullbatt_vchkdrop_uV) uV += desc->fullbatt_vchkdrop_uV; - if (uV >= desc->fullbatt_uV) - return true; + if (uV >= desc->fullbatt_uV) { + is_full = true; + goto out; + } } }