<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/watchdog/watchdog_dev.c, branch linux-6.1.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.1.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.1.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-01-25T23:27:36Z</updated>
<entry>
<title>watchdog: set cdev owner before adding</title>
<updated>2024-01-25T23:27:36Z</updated>
<author>
<name>Curtis Klein</name>
</author>
<published>2023-12-05T19:05:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=06b854238ee54e3c90b37858718c04f55c9b67b1'/>
<id>urn:sha1:06b854238ee54e3c90b37858718c04f55c9b67b1</id>
<content type='text'>
[ Upstream commit 38d75297745f04206db9c29bdd75557f0344c7cc ]

When the new watchdog character device is registered, it becomes
available for opening. This creates a race where userspace may open the
device before the character device's owner is set. This results in an
imbalance in module_get calls as the cdev_get in cdev_open will not
increment the reference count on the watchdog driver module.

This causes problems when the watchdog character device is released as
the module loader's reference will also be released. This makes it
impossible to open the watchdog device later on as it now appears that
the module is being unloaded. The open will fail with -ENXIO from
chrdev_open.

The legacy watchdog device will fail with -EBUSY from the try_module_get
in watchdog_open because it's module owner is the watchdog core module
so it can still be opened but it will fail to get a refcount on the
underlying watchdog device driver.

Fixes: 72139dfa2464 ("watchdog: Fix the race between the release of watchdog_core_data and cdev")
Signed-off-by: Curtis Klein &lt;curtis.klein@hpe.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/20231205190522.55153-1-curtis.klein@hpe.com
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>watchdog: Fix kmemleak in watchdog_cdev_register</title>
<updated>2023-03-11T12:55:23Z</updated>
<author>
<name>Chen Jun</name>
</author>
<published>2022-11-16T01:27:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ac099d94e0480c937aa9172ab64074981ca1a4d3'/>
<id>urn:sha1:ac099d94e0480c937aa9172ab64074981ca1a4d3</id>
<content type='text'>
[ Upstream commit 13721a2ac66b246f5802ba1b75ad8637e53eeecc ]

kmemleak reports memory leaks in watchdog_dev_register, as follows:
unreferenced object 0xffff888116233000 (size 2048):
  comm ""modprobe"", pid 28147, jiffies 4353426116 (age 61.741s)
  hex dump (first 32 bytes):
    80 fa b9 05 81 88 ff ff 08 30 23 16 81 88 ff ff  .........0#.....
    08 30 23 16 81 88 ff ff 00 00 00 00 00 00 00 00  .0#.............
  backtrace:
    [&lt;000000007f001ffd&gt;] __kmem_cache_alloc_node+0x157/0x220
    [&lt;000000006a389304&gt;] kmalloc_trace+0x21/0x110
    [&lt;000000008d640eea&gt;] watchdog_dev_register+0x4e/0x780 [watchdog]
    [&lt;0000000053c9f248&gt;] __watchdog_register_device+0x4f0/0x680 [watchdog]
    [&lt;00000000b2979824&gt;] watchdog_register_device+0xd2/0x110 [watchdog]
    [&lt;000000001f730178&gt;] 0xffffffffc10880ae
    [&lt;000000007a1a8bcc&gt;] do_one_initcall+0xcb/0x4d0
    [&lt;00000000b98be325&gt;] do_init_module+0x1ca/0x5f0
    [&lt;0000000046d08e7c&gt;] load_module+0x6133/0x70f0
    ...

unreferenced object 0xffff888105b9fa80 (size 16):
  comm ""modprobe"", pid 28147, jiffies 4353426116 (age 61.741s)
  hex dump (first 16 bytes):
    77 61 74 63 68 64 6f 67 31 00 b9 05 81 88 ff ff  watchdog1.......
  backtrace:
    [&lt;000000007f001ffd&gt;] __kmem_cache_alloc_node+0x157/0x220
    [&lt;00000000486ab89b&gt;] __kmalloc_node_track_caller+0x44/0x1b0
    [&lt;000000005a39aab0&gt;] kvasprintf+0xb5/0x140
    [&lt;0000000024806f85&gt;] kvasprintf_const+0x55/0x180
    [&lt;000000009276cb7f&gt;] kobject_set_name_vargs+0x56/0x150
    [&lt;00000000a92e820b&gt;] dev_set_name+0xab/0xe0
    [&lt;00000000cec812c6&gt;] watchdog_dev_register+0x285/0x780 [watchdog]
    [&lt;0000000053c9f248&gt;] __watchdog_register_device+0x4f0/0x680 [watchdog]
    [&lt;00000000b2979824&gt;] watchdog_register_device+0xd2/0x110 [watchdog]
    [&lt;000000001f730178&gt;] 0xffffffffc10880ae
    [&lt;000000007a1a8bcc&gt;] do_one_initcall+0xcb/0x4d0
    [&lt;00000000b98be325&gt;] do_init_module+0x1ca/0x5f0
    [&lt;0000000046d08e7c&gt;] load_module+0x6133/0x70f0
    ...

The reason is that put_device is not be called if cdev_device_add fails
and wdd-&gt;id != 0.

watchdog_cdev_register
  wd_data = kzalloc                             [1]
  err = dev_set_name                            [2]
  ..
  err = cdev_device_add
  if (err) {
    if (wdd-&gt;id == 0) {  // wdd-&gt;id != 0
      ..
    }
    return err;  // [1],[2] would be leaked

To fix it, call put_device in all wdd-&gt;id cases.

Fixes: 72139dfa2464 ("watchdog: Fix the race between the release of watchdog_core_data and cdev")
Signed-off-by: Chen Jun &lt;chenjun102@huawei.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/20221116012714.102066-1-chenjun102@huawei.com
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>watchdog: Add tracing events for the most usual watchdog events</title>
<updated>2022-10-12T07:47:02Z</updated>
<author>
<name>Uwe Kleine-König</name>
</author>
<published>2022-10-08T17:46:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e25b091bed4946078c0998e4be77bc56824a9adf'/>
<id>urn:sha1:e25b091bed4946078c0998e4be77bc56824a9adf</id>
<content type='text'>
To simplify debugging which process touches a watchdog and when, add
tracing events for .start(), .set_timeout(), .ping() and .stop().

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Reviewed-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/20221008174602.3972859-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
</content>
</entry>
<entry>
<title>watchdog: Check dev_set_name() return value</title>
<updated>2022-10-02T10:55:38Z</updated>
<author>
<name>Bo Liu</name>
</author>
<published>2022-09-20T02:03:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0e01297212244b5a769aa956854e45da1f0cd1f4'/>
<id>urn:sha1:0e01297212244b5a769aa956854e45da1f0cd1f4</id>
<content type='text'>
It's possible that dev_set_name() returns -ENOMEM, catch and handle this.

Signed-off-by: Bo Liu &lt;liubo03@inspur.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/20220920020312.2383-1-liubo03@inspur.com
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
</content>
</entry>
<entry>
<title>watchdog: Improve watchdog_dev function documentation</title>
<updated>2022-03-27T15:04:08Z</updated>
<author>
<name>Daniel Bristot de Oliveira</name>
</author>
<published>2022-02-11T14:30:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ba6c89ab3b5878364d400b1db4b484e84965f347'/>
<id>urn:sha1:ba6c89ab3b5878364d400b1db4b484e84965f347</id>
<content type='text'>
Adjust function comments to the kernel doc format. It
also adjusts some variable names and adds return values.

No functional change.

Changes from V1:
  Change "Returns" to "Return:" (Randy Dunlap)

Cc: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
Cc: Guenter Roeck &lt;linux@roeck-us.net&gt;
Cc: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Cc: linux-watchdog@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Daniel Bristot de Oliveira &lt;bristot@kernel.org&gt;
Tested-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Acked-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/30378a03e9cd9b5f6e92ec9bf512edc38bad8627.1644589712.git.bristot@kernel.org
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
</content>
</entry>
<entry>
<title>watchdog: Start watchdog in watchdog_set_last_hw_keepalive only if appropriate</title>
<updated>2021-08-22T08:28:12Z</updated>
<author>
<name>Jan Kiszka</name>
</author>
<published>2021-08-01T07:56:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dbe80cf471f940db3063197b7adb1169f89be9ed'/>
<id>urn:sha1:dbe80cf471f940db3063197b7adb1169f89be9ed</id>
<content type='text'>
We must not pet a running watchdog when handle_boot_enabled is off
because this will kick off automatic triggering before userland is
running, defeating the purpose of the handle_boot_enabled control.
Furthermore, don't ping in case watchdog_set_last_hw_keepalive was
called incorrectly when the hardware watchdog is actually not running.

Fixed: cef9572e9af3 ("watchdog: add support for adjusting last known HW keepalive time")
Signed-off-by: Jan Kiszka &lt;jan.kiszka@siemens.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/93d56386-6e37-060b-55ce-84de8cde535f@web.de
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
</content>
</entry>
<entry>
<title>watchdog: introduce watchdog_dev_suspend/resume</title>
<updated>2021-08-22T08:28:08Z</updated>
<author>
<name>Grzegorz Jaszczyk</name>
</author>
<published>2021-06-18T19:50:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=60bcd91aafd22ef62cef9ae2037fa2e1d4da2fb3'/>
<id>urn:sha1:60bcd91aafd22ef62cef9ae2037fa2e1d4da2fb3</id>
<content type='text'>
The watchdog drivers often disable wdog clock during suspend and then
enable it again during resume. Nevertheless the ping worker is still
running and can issue low-level ping while the wdog clock is disabled
causing the system hang. To prevent such condition register pm notifier
in the watchdog core which will call watchdog_dev_suspend/resume and
actually cancel ping worker during suspend and restore it back, if
needed, during resume.

Signed-off-by: Grzegorz Jaszczyk &lt;grzegorz.jaszczyk@linaro.org&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/20210618195033.3209598-2-grzegorz.jaszczyk@linaro.org
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
</content>
</entry>
<entry>
<title>watchdog: Fix NULL pointer dereference when releasing cdev</title>
<updated>2021-08-22T08:28:07Z</updated>
<author>
<name>Curtis Klein</name>
</author>
<published>2021-06-23T06:26:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c7b178dae139f8857edc50888cfbf251cd974a38'/>
<id>urn:sha1:c7b178dae139f8857edc50888cfbf251cd974a38</id>
<content type='text'>
watchdog_hrtimer_pretimeout_stop needs the watchdog device to have a
valid pointer to the watchdog core data to stop the pretimeout hrtimer.
Therefore it needs to be called before the pointers are cleared in
watchdog_cdev_unregister.

Fixes: 7b7d2fdc8c3e ("watchdog: Add hrtimer-based pretimeout feature")
Reported-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Signed-off-by: Curtis Klein &lt;curtis.klein@hpe.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/1624429583-5720-1-git-send-email-curtis.klein@hpe.com
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
</content>
</entry>
<entry>
<title>watchdog: only run driver set_pretimeout op if device supports it</title>
<updated>2021-08-22T08:28:07Z</updated>
<author>
<name>Curtis Klein</name>
</author>
<published>2021-06-26T23:47:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cf6ea9542372a966544d947c17c94048d4883325'/>
<id>urn:sha1:cf6ea9542372a966544d947c17c94048d4883325</id>
<content type='text'>
Some watchdog devices might conditionally support pretimeouts (e.g. if
an interrupt is exposed for the device) but some watchdog drivers might
still define the set_pretimeout operation (e.g. the mtk_wdt driver) and
indicate support at runtime through the WDIOF_PRETIMEOUT flag. If the
kernel is compiled with CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT enabled,
watchdog_set_pretimeout would run the driver specific set_pretimeout
even if WDIOF_PRETIMEOUT is not set which might have unintended
consequences.

So this change checks that the device flags and only runs the driver
operation if pretimeouts are supported.

Signed-off-by: Curtis Klein &lt;curtis.klein@hpe.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/1624751265-24785-1-git-send-email-curtis.klein@hpe.com
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
</content>
</entry>
<entry>
<title>watchdog: Add hrtimer-based pretimeout feature</title>
<updated>2021-06-21T06:49:13Z</updated>
<author>
<name>Curtis Klein</name>
</author>
<published>2021-02-03T20:11:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7b7d2fdc8c3e3f9fdb3558d674e1eeddc16c7d9e'/>
<id>urn:sha1:7b7d2fdc8c3e3f9fdb3558d674e1eeddc16c7d9e</id>
<content type='text'>
This adds the option to use a hrtimer to generate a watchdog pretimeout
event for hardware watchdogs that do not natively support watchdog
pretimeouts.

With this enabled, all watchdogs will appear to have pretimeout support
in userspace. If no pretimeout value is set, there will be no change in
the watchdog's behavior. If a pretimeout value is set for a specific
watchdog that does not have built-in pretimeout support, a timer will be
started that should fire at the specified time before the watchdog
timeout would occur. When the watchdog is successfully pinged, the timer
will be restarted. If the timer is allowed to fire it will generate a
pretimeout event. However because a software timer is used, it may not
be able to fire in every circumstance.

If the watchdog does support a pretimeout natively, that functionality
will be used instead of the hrtimer.

The general design of this feaure was inspired by the software watchdog,
specifically its own pretimeout implementation. However the software
watchdog and this feature are completely independent. They can be used
together; with or without CONFIG_SOFT_WATCHDOG_PRETIMEOUT enabled.

The main advantage of using the hrtimer pretimeout with a hardware
watchdog, compared to running the software watchdog with a hardware
watchdog, is that if the hardware watchdog driver is unable to ping the
watchdog (e.g. due to a bus or communication error), then the hrtimer
pretimeout would still fire whereas the software watchdog would not.

Signed-off-by: Curtis Klein &lt;curtis.klein@hpe.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Link: https://lore.kernel.org/r/1612383090-27110-1-git-send-email-curtis.klein@hpe.com
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Wim Van Sebroeck &lt;wim@linux-watchdog.org&gt;
</content>
</entry>
</feed>
