From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
To: jgq516@gmail.com, dledford@redhat.com, jgg@ziepe.ca
Cc: 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 16:34:08 +0100 [thread overview]
Message-ID: <0c67a2ec-9291-85c1-ba37-2b90849df314@cloud.ionos.com> (raw)
In-Reply-To: <20200110153250.11898-1-guoqing.jiang@cloud.ionos.com>
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.
>
> Thanks,
> Guoqing
>
> drivers/infiniband/core/device.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index 84dd74fe13b8..dca8d9da4a75 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -918,6 +918,7 @@ static int add_one_compat_dev(struct ib_device *device,
> device_del(&cdev->dev);
> add_err:
> put_device(&cdev->dev);
> + kfree(cdev);
> cdev_err:
> xa_release(&device->compat_devs, rnet->id);
> done:
next parent reply other threads:[~2020-01-10 15:34 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 ` Guoqing Jiang [this message]
2020-01-10 15:55 ` [RFC PATCH] RDMA/core: avoid potential memory leak in add_one_compat_dev Jason 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=0c67a2ec-9291-85c1-ba37-2b90849df314@cloud.ionos.com \
--to=guoqing.jiang@cloud.ionos.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.