mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 21:22:09 -04:00
watchdog: Fix memleak in watchdog_cdev_register
[ Upstream commit 5afb6d203d0293512aa2c6ae098274a2a4f6ed02 ]
When watchdog_kworker is NULL, we should free wd_data
before the function returns to prevent memleak.
Fixes: 664a39236e ("watchdog: Introduce hardware maximum heartbeat in watchdog core")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200824024001.25474-1-dinghao.liu@zju.edu.cn
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
9a3ee7177f
commit
a8bbb47d94
1 changed files with 3 additions and 1 deletions
|
|
@ -971,8 +971,10 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
|
|||
wd_data->wdd = wdd;
|
||||
wdd->wd_data = wd_data;
|
||||
|
||||
if (IS_ERR_OR_NULL(watchdog_kworker))
|
||||
if (IS_ERR_OR_NULL(watchdog_kworker)) {
|
||||
kfree(wd_data);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
device_initialize(&wd_data->dev);
|
||||
wd_data->dev.devt = MKDEV(MAJOR(watchdog_devt), wdd->id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue