lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACGkMEuW5po+v-fFPNH6wtVVXD84Bx0UWhe86sHFYXQM39OKRA@mail.gmail.com>
Date:   Fri, 7 Jan 2022 10:34:06 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Xianting Tian <xianting.tian@...ux.alibaba.com>
Cc:     mst <mst@...hat.com>,
        virtualization <virtualization@...ts.linux-foundation.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] virtio-pci: fix memory leak of vp_dev

On Thu, Jan 6, 2022 at 4:31 PM Xianting Tian
<xianting.tian@...ux.alibaba.com> wrote:
>
> In virtio_pci_probe(), vp_dev will not be freed if it goes to
> "err_register" branch. fix it
>
> Signed-off-by: Xianting Tian <xianting.tian@...ux.alibaba.com>

So we had this:

commit 33635bd976fb4c3ccf0cfbb81a8d29bb87760607
Author: weiping zhang <zhangweiping@...ichuxing.com>
Date:   Thu Dec 21 20:40:24 2017 +0800

    virtio_pci: don't kfree device on register failure

    As mentioned at drivers/base/core.c:
    /*
     * NOTE: _Never_ directly free @dev after calling this function, even
     * if it returned an error! Always use put_device() to give up the
     * reference initialized in this function instead.
     */
    so we don't free vp_dev until vp_dev->vdev.dev.release be called.

    Signed-off-by: weiping zhang <zhangweiping@...ichuxing.com>
    Reviewed-by: Cornelia Huck <cohuck@...hat.com>
    Signed-off-by: Michael S. Tsirkin <mst@...hat.com>

Any reason that the above fix is wrong?

Thanks

> ---
>  drivers/virtio/virtio_pci_common.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
> index fdbde1db5..48b5ac15e 100644
> --- a/drivers/virtio/virtio_pci_common.c
> +++ b/drivers/virtio/virtio_pci_common.c
> @@ -602,8 +602,7 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
>  err_enable_device:
>         if (reg_dev)
>                 put_device(&vp_dev->vdev.dev);
> -       else
> -               kfree(vp_dev);
> +       kfree(vp_dev);
>         return rc;
>  }
>
> --
> 2.17.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ