summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2026-10-27 09:02:55 -0700
committerGuenter Roeck <linux@roeck-us.net>2026-11-16 13:26:11 -0800
commit32bcf30c28e0ce850b3ca58d4ec3041ee18e7931 (patch)
tree89e0b1f61757dca2d21156c08d080c42169b46ad /rust/kernel/alloc
parentac65fcce7f4d6e327ab7b755f999a8b15381d3f0 (diff)
watchdog: core: Clear wd_data pointer on errors
In watchdog_cdev_register(), if device registration fails after the core watchdog_core_data structure is allocated and assigned to the persistent watchdog_device structure, the function frees the data but leaves a dangling pointer. During device registration, watchdog_cdev_register() links the newly allocated wd_data to wdd->wd_data. If a subsequent initialization step fails, such as the watchdog_kworker validation, dev_set_name(), misc_register(), or cdev_device_add(), the function cleans up by freeing wd_data via kfree() or put_device(). However, it fails to clear the wdd->wd_data pointer before returning. Furthermore, if cdev_device_add() fails after misc_register() exposed /dev/watchdog to userspace, a concurrent open may hold a reference to wd_data while the caller frees wdd, leaving wd_data->wdd dangling. Fix the problem by clearing wdd->wd_data on all error paths during watchdog registration, and clearing wd_data->wdd under wd_data->lock if cdev_device_add() fails. Fixes: b4ffb1909843 ("watchdog: Separate and maintain variables based on variable lifetime") Reported-by: Reported-by: Sashiko <sashiko@sashiko.dev> Link: https://sashiko.dev/#/bug/linux-50fc8217-05c7-468f-a867-6ba925b50226 Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Link: https://patch.msgid.link/20261027160302.2519282-2-linux@roeck-us.net Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'rust/kernel/alloc')
0 files changed, 0 insertions, 0 deletions