qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] vfio/iommufd: Fix memory leak


From: Eric Auger
Subject: Re: [PATCH] vfio/iommufd: Fix memory leak
Date: Wed, 13 Mar 2024 22:11:45 +0100
User-agent: Mozilla Thunderbird


On 3/13/24 22:06, Cédric Le Goater wrote:
> Make sure variable contents is freed if scanf fails.
>
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Yi Liu <yi.l.liu@intel.com>
> Cc: Zhenzhong Duan <zhenzhong.duan@intel.com>
> Fixes: CID 1540007
> Fixes: 5ee3dc7af785 ("vfio/iommufd: Implement the iommufd backend")
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks!

Eric
> ---
>  hw/vfio/iommufd.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index 
> a75a785e90c64cdcc4d10c88d217801b3f536cdb..cd549e0ee8573e75772c51cc96153762a6bc8550
>  100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -152,9 +152,8 @@ static int iommufd_cdev_getfd(const char *sysfs_path, 
> Error **errp)
>  
>      if (sscanf(contents, "%d:%d", &major, &minor) != 2) {
>          error_setg(errp, "failed to get major:minor for \"%s\"", 
> vfio_dev_path);
> -        goto out_free_dev_path;
> +        goto out_free_contents;
>      }
> -    g_free(contents);
>      vfio_devt = makedev(major, minor);
>  
>      vfio_path = g_strdup_printf("/dev/vfio/devices/%s", dent->d_name);
> @@ -166,6 +165,8 @@ static int iommufd_cdev_getfd(const char *sysfs_path, 
> Error **errp)
>      trace_iommufd_cdev_getfd(vfio_path, ret);
>      g_free(vfio_path);
>  
> +out_free_contents:
> +    g_free(contents);
>  out_free_dev_path:
>      g_free(vfio_dev_path);
>  out_close_dir:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]