From: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
To: mehdi.djait@bootlin.com
Cc: mchehab@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org, wanghr2026@mail.zgclab.edu.cn
Subject: [PATCH] media: i2c: tw9900: disable vdd on resume failure
Date: Thu, 19 Nov 2026 16:14:55 +0800 [thread overview]
Message-ID: <1795076095438-5-e3a836e0@mail.zgclab.edu.cn> (raw)
tw9900_runtime_resume() enables the vdd regulator but if the init register
writes fail the regulator is left enabled and the resume error sets
runtime_error, after which runtime_suspend() is never called again. The
only regulator_disable() lives in runtime_suspend(), so a single I2C error
in the first resume (which happens during probe's check_id) leaves the rail
enabled until reboot, even across unbind and probe retries.
Disable the regulator when the register write fails.
Signed-off-by: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
Fixes: 918b14a26b12 ("media: i2c: Introduce a driver for the Techwell TW9900 decoder")
---
diff --git a/drivers/media/i2c/tw9900.c b/drivers/media/i2c/tw9900.c
index 51db5d5ddbde..b4fb566807a8 100644
--- a/drivers/media/i2c/tw9900.c
+++ b/drivers/media/i2c/tw9900.c
@@ -624,6 +624,8 @@ static int tw9900_runtime_resume(struct device *dev)
ret = tw9900_write_array(tw9900->client, tw9900_init_regs,
ARRAY_SIZE(tw9900_init_regs));
+ if (ret)
+ regulator_disable(tw9900->regulator);
mutex_unlock(&tw9900->mutex);
---
PoC reproduction (7.4.0-rc2, arm64 QEMU virt, unmodified kernel):
Route 1 (i2c-stub, no DT injection needed):
modprobe i2c-stub chip_addr=0x2c
echo "tw9900 0x40" > /sys/bus/i2c/devices/i2c-0/new_device
The probe triggers the first runtime_resume during check_id and the init
register write fails on the unanswered address.
Result:
i2c i2c-0: new_device: Instantiated device tw9900 at 0x40
tw9900 0-0040: write reg error: -19
WARNING: drivers/regulator/core.c:2678 at _regulator_put
The regulator-dummy use count rises by one on every failed probe (and on
every delete/new_device retry) and never drops, because runtime_suspend is
blocked by the runtime_error state.
Note: the PoC was generated with AI assistance and the vulnerability was
found by static analysis. Triggering the failed probe via sysfs requires
root, so this is not a security fix, but it prevents a potential resource
leak on a failed probe.
reply other threads:[~2026-11-19 8:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1795076095438-5-e3a836e0@mail.zgclab.edu.cn \
--to=wanghr2026@mail.zgclab.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mehdi.djait@bootlin.com \
/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 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®