From: Jason Gunthorpe <jgg@ziepe.ca>
To: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Cc: jgq516@gmail.com, dledford@redhat.com,
Parav Pandit <parav@mellanox.com>,
linux-rdma@vger.kernel.org
Subject: Re: [RFC PATCH] RDMA/core: avoid potential memory leak in add_one_compat_dev
Date: Fri, 10 Jan 2020 11:55:11 -0400 [thread overview]
Message-ID: <20200110155511.GD8765@ziepe.ca> (raw)
In-Reply-To: <0c67a2ec-9291-85c1-ba37-2b90849df314@cloud.ionos.com>
On Fri, Jan 10, 2020 at 04:34:08PM +0100, Guoqing Jiang wrote:
> Forget to cc list, sorry.
>
> On 1/10/20 4:32 PM, jgq516@gmail.com wrote:
> > From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
> >
> > In add_one_compat_dev, if failure happens after cdev is allocated,
> > so we need to free the memory accordingly.
> >
> > Fixes: 4e0f7b9070726 ("RDMA/core: Implement compat device/sysfs tree in net namespace")
> > Cc: Parav Pandit <parav@mellanox.com>
> > Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
> > Hi,
> >
> > When reading the code, it looks no place to free cdev under those err condition.
> > And I guess remove_one_compat_dev needs to free cdev as well, something like:
> >
> > @@ -937,6 +937,8 @@ static void remove_one_compat_dev(struct ib_device *device, u32 id)
> > ib_free_port_attrs(cdev);
> > device_del(&cdev->dev);
> > put_device(&cdev->dev);
> > + kfree(cdev);
> > + cdev = NULL;
> > }
> > }
> >
> > But since I am not know well about the code, so this is RFC.
put_device triggers compatdev_release which does the free
Jason
prev parent reply other threads:[~2020-01-10 15:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200110153250.11898-1-guoqing.jiang@cloud.ionos.com>
2020-01-10 15:34 ` [RFC PATCH] RDMA/core: avoid potential memory leak in add_one_compat_dev Guoqing Jiang
2020-01-10 15:55 ` Jason Gunthorpe [this message]
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=20200110155511.GD8765@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=dledford@redhat.com \
--cc=guoqing.jiang@cloud.ionos.com \
--cc=jgq516@gmail.com \
--cc=linux-rdma@vger.kernel.org \
--cc=parav@mellanox.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;
as well as URLs for NNTP newsgroup(s).