[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180522004846.GC3255@kudzu.us>
Date: Mon, 21 May 2018 20:48:47 -0400
From: Jon Mason <jdmason@...zu.us>
To: Arvind Yadav <arvind.yadav.cs@...il.com>
Cc: dave.jiang@...el.com, allenbh@...il.com,
linux-kernel@...r.kernel.org, linux-ntb@...glegroups.com
Subject: Re: [PATCH] ntb_transport: use put_device() instead of kfree()
On Fri, Mar 09, 2018 at 04:03:24PM +0530, Arvind Yadav wrote:
> Never directly free @dev after calling device_register(), even
> if it returned an error! Always use put_device() to give up the
> reference initialized.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
> ---
> drivers/ntb/ntb_transport.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index 9878c48..8182a3a 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -393,7 +393,7 @@ int ntb_transport_register_client_dev(char *device_name)
>
> rc = device_register(dev);
> if (rc) {
> - kfree(client_dev);
> + put_device(dev);
Now we are leaking client_dev, which is bigger than just dev. I think
we are going to need both now.
Thanks,
Jon
> goto err;
> }
>
> --
> 1.9.1
>
Powered by blists - more mailing lists