lkml.org 
[lkml]   [2026]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] hwmon: (fschmd) avoid client->dev dereference in watchdog_release
Date
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

\
 
 \ /
  Last update: 2026-05-23 07:14    [W:0.050 / U:1.915 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog