From: Alex Williamson <alex.williamson@redhat.com>
To: Colin King <colin.king@canonical.com>
Cc: Kirti Wankhede <kwankhede@nvidia.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jason Gunthorpe <jgg@ziepe.ca>,
kvm@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] vfio/mdpy: Fix memory leak of object mdev_state->vconfig
Date: Fri, 25 Jun 2021 09:04:46 -0600 [thread overview]
Message-ID: <20210625090446.46da71e7.alex.williamson@redhat.com> (raw)
In-Reply-To: <20210622183710.28954-1-colin.king@canonical.com>
On Tue, 22 Jun 2021 19:37:10 +0100
Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In the case where the call to vfio_register_group_dev fails the error
> return path kfree's mdev_state but not mdev_state->vconfig. Fix this
> by kfree'ing mdev_state->vconfig before returning.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 437e41368c01 ("vfio/mdpy: Convert to use vfio_register_group_dev()")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> samples/vfio-mdev/mdpy.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
> index 7e9c9df0f05b..393c9df6f6a0 100644
> --- a/samples/vfio-mdev/mdpy.c
> +++ b/samples/vfio-mdev/mdpy.c
> @@ -261,6 +261,7 @@ static int mdpy_probe(struct mdev_device *mdev)
>
> ret = vfio_register_group_dev(&mdev_state->vdev);
> if (ret) {
> + kfree(mdev_state->vconfig);
> kfree(mdev_state);
> return ret;
> }
Applied to vfio next branch for v5.14, thanks!
Alex
prev parent reply other threads:[~2021-06-25 15:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 18:37 [PATCH][next] vfio/mdpy: Fix memory leak of object mdev_state->vconfig Colin King
2021-06-22 18:58 ` Jason Gunthorpe
2021-06-22 20:39 ` Alex Williamson
2021-06-25 15:04 ` Alex Williamson [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=20210625090446.46da71e7.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=colin.king@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=jgg@ziepe.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
/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).