* [PATCH] media: i2c: dw9719: power down on detection errors
@ 2026-09-13 4:18 Myeonghun Pak
2026-10-17 21:40 ` Chris Simpson
0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-09-13 4:18 UTC (permalink / raw)
To: Daniel Scally, Sakari Ailus, Mauro Carvalho Chehab
Cc: Hans de Goede, linux-media, linux-kernel, stable, Ijae Kim
Moving chip detection into dw9719_power_up() introduced direct returns
after the regulator has been enabled. An INFO register read failure or an
unrecognized ID bypasses the power-down path, while probe only cleans up
the media entity and controls after a power-up error.
Route both detection errors through the existing power-down check. Preserve
the read error or -ENXIO and leave the successful power-up and regulator
enable failure paths unchanged.
This issue was identified during our ongoing static-analysis research while
reviewing kernel code.
Fixes: 2a1551665a85 ("media: dw9719: Add DW9761 support")
Cc: stable@vger.kernel.org
Assisted-by: OpenAI:GPT-5.6
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
drivers/media/i2c/dw9719.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c
index 3b7ba88fd..8a34abe18 100644
--- a/drivers/media/i2c/dw9719.c
+++ b/drivers/media/i2c/dw9719.c
@@ -150,7 +150,7 @@ static int dw9719_power_up(struct dw9719_device *dw9719, bool detect)
ret = cci_read(dw9719->regmap, DW9719_INFO, &val, NULL);
if (ret < 0)
- return ret;
+ goto out;
switch (val) {
case DW9719_ID:
@@ -168,7 +168,8 @@ static int dw9719_power_up(struct dw9719_device *dw9719, bool detect)
default:
dev_err(dw9719->dev,
"Error unknown device id 0x%02llx\n", val);
- return -ENXIO;
+ ret = -ENXIO;
+ goto out;
}
props:
@@ -218,6 +219,7 @@ static int dw9719_power_up(struct dw9719_device *dw9719, bool detect)
cci_write(dw9719->regmap, DW9719_VCM_FREQ, dw9719->vcm_freq, &ret);
}
+out:
if (ret)
dw9719_power_down(dw9719);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] media: i2c: dw9719: power down on detection errors
2026-09-13 4:18 [PATCH] media: i2c: dw9719: power down on detection errors Myeonghun Pak
@ 2026-10-17 21:40 ` Chris Simpson
0 siblings, 0 replies; 2+ messages in thread
From: Chris Simpson @ 2026-10-17 21:40 UTC (permalink / raw)
To: Myeonghun Pak
Cc: Hans de Goede, linux-media, linux-kernel, stable, Ijae Kim,
Daniel Scally, Sakari Ailus, Mauro Carvalho Chehab
On Sun, 13 Sep 2026 00:18:28 -0400, Myeonghun Pak wrote:
> Moving chip detection into dw9719_power_up() introduced direct returns
> after the regulator has been enabled. An INFO register read failure or
> an unrecognized ID bypasses the power-down path, while probe only
> cleans up the media entity and controls after a power-up error.
I found the same leak independently while adding DW9800W support for
the Surface Pro 9, and wrote the same change.
I tested both error paths on a Surface Pro 9 (DW9800W, ACPI, a 7.2.11
distro kernel with the linux-surface patches), forcing them with a
test-only hook: an unknown INFO id, and a failed INFO read. Without your
patch, each failed probe hit the WARN_ON(regulator->enable_count) in
_regulator_put(), reported as regulator_put() because it is inlined
there, and the (dummy) supply's num_users stayed one higher. With your
patch, neither happened. An equivalent change in my tree also runs fine
through the normal path, including runtime and system suspend.
Reviewed-by: Chris Simpson <chris@nilk.net>
Tested-by: Chris Simpson <chris@nilk.net>
The patch still applies cleanly to the media-committers next branch.
Thanks,
Chris
Made with AI assistance. Written by Claude Opus 5.5 (drafting), with
review by Claude Fable 5.1 and testing by Claude Opus 5.5, under the
direction of Chris Simpson <chris@nilk.net>, who reviewed and approved
it.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-17 21:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-13 4:18 [PATCH] media: i2c: dw9719: power down on detection errors Myeonghun Pak
2026-10-17 21:40 ` Chris Simpson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®