[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] vfio/common: Do not g_free in vfio_get_iommu_info
From: |
Nicolin Chen |
Subject: |
[PATCH] vfio/common: Do not g_free in vfio_get_iommu_info |
Date: |
Fri, 9 Sep 2022 17:42:45 -0700 |
Its caller vfio_connect_container() assigns a default value
to info->iova_pgsizes, even if vfio_get_iommu_info() fails.
This would result in a "Segmentation fault" error, when the
VFIO_IOMMU_GET_INFO ioctl errors out.
Since the caller has g_free already, drop the g_free in its
rollback routine and add a line of comments to highlight it.
Fixes: 87ea529c50 ("vfio: Get migration capability flags for container")
Cc: Kirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
hw/vfio/common.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index ace9562a9b..51b2e05c76 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1940,6 +1940,7 @@ static int vfio_init_container(VFIOContainer *container,
int group_fd,
return 0;
}
+/* The caller is responsible for g_free(*info) */
static int vfio_get_iommu_info(VFIOContainer *container,
struct vfio_iommu_type1_info **info)
{
@@ -1951,8 +1952,6 @@ again:
(*info)->argsz = argsz;
if (ioctl(container->fd, VFIO_IOMMU_GET_INFO, *info)) {
- g_free(*info);
- *info = NULL;
return -errno;
}
--
2.17.1
- [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info,
Nicolin Chen <=
- Re: [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info, Cornelia Huck, 2022/09/12
- Re: [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info, Nicolin Chen, 2022/09/12
- Re: [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info, Alex Williamson, 2022/09/14
- Re: [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info, Alex Williamson, 2022/09/14
- Re: [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info, Nicolin Chen, 2022/09/14
- Re: [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info, Alex Williamson, 2022/09/14
- Re: [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info, Alex Williamson, 2022/09/14
- Re: [PATCH] vfio/common: Do not g_free in vfio_get_iommu_info, Nicolin Chen, 2022/09/14