All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Sasha Levin <sashal@kernel.org>,
	sre@kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.12 05/26] power: supply: collie: Fix wakeup source leaks on device unbind
Date: Fri, 30 May 2025 08:39:51 -0400	[thread overview]
Message-ID: <20250530124012.2575409-5-sashal@kernel.org> (raw)
In-Reply-To: <20250530124012.2575409-1-sashal@kernel.org>

From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

[ Upstream commit c73d19f89cb03c43abbbfa3b9caa1b8fc719764c ]

Device can be unbound, so driver must also release memory for the wakeup
source.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20250406202730.55096-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

Perfect! This confirms the pattern. Now let me analyze the commit:
**YES** This commit should be backported to stable kernel trees. Here's
my extensive analysis: ## Justification for Backporting ### 1. **Bug Fix
Nature** The commit fixes a resource leak bug where wakeup sources are
not properly cleaned up when the device is unbound. This is a clear bug
fix that affects system resource management. ### 2. **Matching Pattern
with Similar Commits** This commit follows the exact same pattern as the
similar commits marked "YES" for backporting: - **Similar Commit #1
(gpio: mpc8xxx)** and **Similar Commit #3 (gpio: zynq)** both have
identical commit messages and fix the same type of wakeup source leak by
adding `device_init_wakeup(&pdev->dev, 0)` in the remove function. - All
these commits are from the same author (Krzysztof Kozlowski) and have
`Cc: stable@vger.kernel.org` in their commit messages, indicating
explicit intention for stable tree inclusion. ### 3. **Code Analysis**
The code change is minimal and surgical: - **Single line addition**:
`device_init_wakeup(&ucb->dev, 0);` in the `collie_bat_remove()`
function - **Proper cleanup ordering**: The line is added at the
beginning of the remove function, which is the correct place for
resource cleanup - **Symmetric operation**: The probe function calls
`device_init_wakeup(&ucb->dev, 1)` at line 414, and now the remove
function properly disables it with `device_init_wakeup(&ucb->dev, 0)`
### 4. **Resource Leak Prevention** From examining the kernel tree, I
can see that: - The probe function enables wakeup with
`device_init_wakeup(&ucb->dev, 1)` - Without this fix, when the driver
is unbound, the wakeup source memory is leaked - This follows the
established pattern seen in other drivers like gpio-zynq.c where
`device_init_wakeup(&pdev->dev, 0)` is called in remove functions ### 5.
**Low Risk Assessment** - **Minimal scope**: Only affects the collie
battery driver cleanup path - **No functional changes**: Doesn't change
driver behavior, only fixes resource cleanup - **No architectural
changes**: Single line addition for proper resource management - **No
new features**: Pure bug fix ### 6. **Stable Tree Criteria Compliance**
- ✅ **Important bug fix**: Prevents resource leaks - ✅ **Minimal risk**:
Single line, well-understood API call - ✅ **No new features**: Only
fixes cleanup - ✅ **Small and contained**: Confined to one driver's
remove function - ✅ **Clear side effects**: Only positive effect of
proper resource cleanup ### 7. **Explicit Stable Tree Intent** The
commit message doesn't include `Cc: stable@vger.kernel.org`, but the
similar commits #1 and #3 from the same author fixing identical issues
do have this tag, suggesting this is part of a series addressing wakeup
source leaks across multiple drivers. The fix is essential for proper
resource management and follows established kernel patterns for wakeup
source cleanup during device unbinding.

 drivers/power/supply/collie_battery.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/power/supply/collie_battery.c b/drivers/power/supply/collie_battery.c
index 68390bd1004f0..3daf7befc0bf6 100644
--- a/drivers/power/supply/collie_battery.c
+++ b/drivers/power/supply/collie_battery.c
@@ -440,6 +440,7 @@ static int collie_bat_probe(struct ucb1x00_dev *dev)
 
 static void collie_bat_remove(struct ucb1x00_dev *dev)
 {
+	device_init_wakeup(&ucb->dev, 0);
 	free_irq(gpiod_to_irq(collie_bat_main.gpio_full), &collie_bat_main);
 	power_supply_unregister(collie_bat_bu.psy);
 	power_supply_unregister(collie_bat_main.psy);
-- 
2.39.5


  parent reply	other threads:[~2025-05-30 12:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30 12:39 [PATCH AUTOSEL 6.12 01/26] ACPICA: fix acpi operand cache leak in dswstate.c Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 02/26] ASoC: amd: yc: Add quirk for Lenovo Yoga Pro 7 14ASP9 Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 03/26] clocksource: Fix the CPUs' choice in the watchdog per CPU verification Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 04/26] tools/nolibc: use intmax definitions from compiler Sasha Levin
2025-05-30 12:39 ` Sasha Levin [this message]
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 06/26] mmc: Add quirk to disable DDR50 tuning Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 07/26] ACPICA: Avoid sequence overread in call to strncmp() Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 08/26] mmc: sdhci-esdhc-imx: Save tuning value when card stays powered in suspend Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 09/26] ASoC: tas2770: Power cycle amp on ISENSE/VSENSE change Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 10/26] ASoC: intel/sdw_utils: Assign initial value in asoc_sdw_rt_amp_spk_rtd_init() Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 11/26] ACPI: bus: Bail out if acpi_kobj registration fails Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 12/26] ACPI: Add missing prototype for non CONFIG_SUSPEND/CONFIG_X86 case Sasha Levin
2025-05-30 12:39 ` [PATCH AUTOSEL 6.12 13/26] ACPICA: fix acpi parse and parseext cache leaks Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 14/26] ACPICA: Apply pack(1) to union aml_resource Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 15/26] ALSA: hda: cs35l41: Fix swapped l/r audio channels for Acer Helios laptops Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 16/26] power: supply: bq27xxx: Retrieve again when busy Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 17/26] pmdomain: core: Reset genpd->states to avoid freeing invalid data Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 18/26] ACPICA: utilities: Fix overflow check in vsnprintf() Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 19/26] platform-msi: Add msi_remove_device_irq_domain() in platform_device_msi_free_irqs_all() Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 20/26] ASoC: tegra210_ahub: Add check to of_device_get_match_data() Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 21/26] Make 'cc-option' work correctly for the -Wno-xyzzy pattern Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 22/26] gpiolib: of: Add polarity quirk for s5m8767 Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 23/26] PM: runtime: fix denying of auto suspend in pm_suspend_timer_fn() Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 24/26] tools/nolibc: use pselect6_time64 if available Sasha Levin
2025-05-30 12:40   ` Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 25/26] power: supply: max17040: adjust thermal channel scaling Sasha Levin
2025-05-30 12:40 ` [PATCH AUTOSEL 6.12 26/26] ACPI: battery: negate current when discharging Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250530124012.2575409-5-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=sebastian.reichel@collabora.com \
    --cc=sre@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.