lkml.org 
[lkml]   [2018]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] vfio: fix potential memory leak in vfio_msi_cap_len
On Mon, 27 Aug 2018 05:47:21 -0700
Li Qiang <liq3ea@gmail.com> wrote:

> Free the vdev->msi_perm in error path.
>
> Signed-off-by: Li Qiang <liq3ea@gmail.com>
> ---
> drivers/vfio/pci/vfio_pci_config.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
> index 115a36f6f403..62023b4a373b 100644
> --- a/drivers/vfio/pci/vfio_pci_config.c
> +++ b/drivers/vfio/pci/vfio_pci_config.c
> @@ -1180,8 +1180,10 @@ static int vfio_msi_cap_len(struct vfio_pci_device *vdev, u8 pos)
> return -ENOMEM;
>
> ret = init_pci_cap_msi_perm(vdev->msi_perm, len, flags);
> - if (ret)
> + if (ret) {
> + kfree(vdev->msi_perm);
> return ret;
> + }
>
> return len;
> }

Fix looks correct to me, I'll queue this for v4.20 with Eric's R-b.
Thanks,

Alex

\
 
 \ /
  Last update: 2018-09-04 17:53    [W:0.241 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site