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 C58D246EF72; Tue, 21 Jul 2026 18:31:55 +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=1784658716; cv=none; b=CihuaLC7db2BxhvfN8WfVi/mw4ldpcWmFz2YTvGEt1rqfUrEFWiYvLjKy5Caw7qCfRduWlJLXldarlawY9hqqzIg+F/FmRmFY80Lh8tXB+fzhSzQphyvNKsx3U8GliIISfVMOwjBxjcK92v2czmw1rDjr3D8xvhaBxz14aQ1ec4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658716; c=relaxed/simple; bh=IyQO3Q+wxSB4k3FHrhGeFG7SDrZJ73lhTfUTmPql5Dw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n0X5vqLQBmZnHpHehKqLZ6R5hBdL/d7D3l4SnV4CfRggEB4MdkGHEoihMDLpnggelaszDeHYqcRpxv4/nhFvPdlhv6T/7QKSkkCJERtSTuNktvNsXbY8xKdL4X/HAcgXuyH0q+M7EKo1DX2LjkNL2IuoqMJEyLhRy/lg2dLMnH4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mWtIG4Va; 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="mWtIG4Va" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3823B1F000E9; Tue, 21 Jul 2026 18:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784658715; bh=lYv12DG6hlBIr8gpjyFgK2XpVWAiGOCcyWyY6NxpIiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mWtIG4Va9LFm5qSXcUjzu3ojzDKxAIKnnz7/wJ77I2s1cTOLw/Pkg/82qJf6KwMV2 OhKkbDtbT9wF77coyKiHUGR77pot3FJeZax1K1Vr3Bw1s68TTDzJHziqiitLTfVsNm uIKkR9LQXycaGQohDb3vCe2Y4PauW3toWnKqslnE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, WenTao Liang , Sebastian Reichel Subject: [PATCH 6.18 1246/1611] power: supply: charger-manager: fix refcount leak in is_full_charged() Date: Tue, 21 Jul 2026 17:22:42 +0200 Message-ID: <20260721152543.469060681@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@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.18-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 @@ -303,8 +303,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; + } } }