watchdog: Use put_device on error
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Mon, 24 Aug 2020 03:12:30 +0000 (11:12 +0800)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Wed, 14 Oct 2020 13:02:24 +0000 (15:02 +0200)
We should use put_device() instead of freeing device
directly after device_initialize().

Fixes: cb36e29bb0e4b ("watchdog: initialize device before misc_register")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200824031230.31050-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>
drivers/watchdog/watchdog_dev.c

index 785270e..bcf01af 100644 (file)
@@ -1023,7 +1023,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
                                pr_err("%s: a legacy watchdog module is probably present.\n",
                                        wdd->info->identity);
                        old_wd_data = NULL;
-                       kfree(wd_data);
+                       put_device(&wd_data->dev);
                        return err;
                }
        }