[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <29536273-4cd5-5530-083a-c8b8e42e1eb1@roeck-us.net>
Date: Thu, 13 Oct 2022 06:53:10 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Manank Patel <pmanank200502@...il.com>
Cc: linux-watchdog@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers: watchdog: exar_wdt.c fix use after free
On 10/13/22 02:54, Manank Patel wrote:
> fix use after free by storing the result of PTR_ERR(n->pdev)
> to a local variable before returning.
>
> Signed-off-by: Manank Patel <pmanank200502@...il.com>
Reviewed-by: Guenter Roeck <linux@...ck-us.net>
> ---
> drivers/watchdog/exar_wdt.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/exar_wdt.c b/drivers/watchdog/exar_wdt.c
> index 35058d8b21bc..7c61ff343271 100644
> --- a/drivers/watchdog/exar_wdt.c
> +++ b/drivers/watchdog/exar_wdt.c
> @@ -355,8 +355,10 @@ static int __init exar_wdt_register(struct wdt_priv *priv, const int idx)
> &priv->wdt_res, 1,
> priv, sizeof(*priv));
> if (IS_ERR(n->pdev)) {
> + int err = PTR_ERR(n->pdev);
> +
> kfree(n);
> - return PTR_ERR(n->pdev);
> + return err;
> }
>
> list_add_tail(&n->list, &pdev_list);
Powered by blists - more mailing lists