linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] watchdog: Use put_device on error
@ 2020-08-24  3:12 Dinghao Liu
  2020-08-24 13:37 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2020-08-24  3:12 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Wim Van Sebroeck, Guenter Roeck, Krzysztof Sobota,
	Alexander Sverdlin, linux-watchdog, linux-kernel

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>
---

Changelog:

v2: - Use put_device() instead of just removing kfree.
      Move the memleak part to a separate patch.
---
 drivers/watchdog/watchdog_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 6798addabd5a..b0fa7f31b1b6 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -1021,7 +1021,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;
 		}
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [v2] watchdog: Use put_device on error
  2020-08-24  3:12 [PATCH] [v2] watchdog: Use put_device on error Dinghao Liu
@ 2020-08-24 13:37 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-08-24 13:37 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Wim Van Sebroeck, Krzysztof Sobota, Alexander Sverdlin,
	linux-watchdog, linux-kernel

On Mon, Aug 24, 2020 at 11:12:30AM +0800, Dinghao Liu wrote:
> 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>

> ---
> 
> Changelog:
> 
> v2: - Use put_device() instead of just removing kfree.
>       Move the memleak part to a separate patch.
> ---
>  drivers/watchdog/watchdog_dev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 6798addabd5a..b0fa7f31b1b6 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -1021,7 +1021,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;
>  		}
>  	}
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-24 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24  3:12 [PATCH] [v2] watchdog: Use put_device on error Dinghao Liu
2020-08-24 13:37 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).