From: Jon Mason <jdmason@kudzu.us>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: dave.jiang@intel.com, allenbh@gmail.com,
linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com
Subject: Re: [PATCH] ntb_transport: use put_device() instead of kfree()
Date: Mon, 21 May 2018 20:48:47 -0400 [thread overview]
Message-ID: <20180522004846.GC3255@kudzu.us> (raw)
In-Reply-To: <6717325ea580df9a0294db6f83fd72a5db3daad9.1520591515.git.arvind.yadav.cs@gmail.com>
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@gmail.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
>
next prev parent reply other threads:[~2018-05-22 0:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-09 10:33 [PATCH] ntb_transport: use put_device() instead of kfree() Arvind Yadav
2018-03-09 16:46 ` Logan Gunthorpe
2018-05-22 0:48 ` Jon Mason [this message]
2018-05-22 16:56 ` Logan Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180522004846.GC3255@kudzu.us \
--to=jdmason@kudzu.us \
--cc=allenbh@gmail.com \
--cc=arvind.yadav.cs@gmail.com \
--cc=dave.jiang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ntb@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox