From: Chen-Shi-Hong <eric039eric@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
Chen-Shi-Hong <eric039eric@gmail.com>
Subject: [PATCH] hwmon: (fschmd) avoid client->dev dereference in watchdog_release
Date: Sat, 23 May 2026 13:10:53 +0800 [thread overview]
Message-ID: <20260523051117.9400-1-eric039eric@gmail.com> (raw)
fschmd_remove() can detach the i2c client while the watchdog device
is still open.
If watchdog_release() later takes the unexpected-close path, it calls
watchdog_trigger() and then logs the event with dev_crit() using
data->client->dev. However, the client may already have been cleared
by the remove path.
watchdog_trigger() already checks whether data->client is still valid
and returns -ENODEV if the client is gone. Use its return value to
decide whether to emit the message, and log with watchdog_name instead
of dereferencing data->client->dev.
This avoids relying on a device pointer that may no longer be valid
during release after device removal.
Signed-off-by: Chen-Shi-Hong <eric039eric@gmail.com>
---
drivers/hwmon/fschmd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index 1211fa2259e5..d1e7fc72e81f 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -834,9 +834,9 @@ static int watchdog_release(struct inode *inode, struct file *filp)
watchdog_stop(data);
data->watchdog_expect_close = 0;
} else {
- watchdog_trigger(data);
- dev_crit(&data->client->dev,
- "unexpected close, not stopping watchdog!\n");
+ if (!watchdog_trigger(data))
+ pr_crit("%s: unexpected close, not stopping watchdog!\n",
+ data->watchdog_name);
}
clear_bit(0, &data->watchdog_is_open);
--
2.53.0
next reply other threads:[~2026-05-23 5:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 5:10 Chen-Shi-Hong [this message]
2026-05-23 5:44 ` [PATCH] hwmon: (fschmd) avoid client->dev dereference in watchdog_release sashiko-bot
2026-05-23 13:24 ` Guenter Roeck
2026-05-23 13:44 ` Chen-Shi-Hong
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=20260523051117.9400-1-eric039eric@gmail.com \
--to=eric039eric@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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.