mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-30 21:47:18 +00:00
node_device: Fix memory leak in udevProcessMediatedDevice
One of the paths returned -1 directly without going through the cleanup section. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
b564ce40aa
commit
d5b3c62e81
@ -1020,10 +1020,9 @@ static int
|
|||||||
udevProcessMediatedDevice(struct udev_device *dev,
|
udevProcessMediatedDevice(struct udev_device *dev,
|
||||||
virNodeDeviceDef *def)
|
virNodeDeviceDef *def)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
int iommugrp = -1;
|
int iommugrp = -1;
|
||||||
char *linkpath = NULL;
|
g_autofree char *linkpath = NULL;
|
||||||
char *canonicalpath = NULL;
|
g_autofree char *canonicalpath = NULL;
|
||||||
virNodeDevCapMdev *data = &def->caps->data.mdev;
|
virNodeDevCapMdev *data = &def->caps->data.mdev;
|
||||||
struct udev_device *parent_device = NULL;
|
struct udev_device *parent_device = NULL;
|
||||||
|
|
||||||
@ -1039,19 +1038,19 @@ udevProcessMediatedDevice(struct udev_device *dev,
|
|||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("failed to wait for file '%s' to appear"),
|
_("failed to wait for file '%s' to appear"),
|
||||||
linkpath);
|
linkpath);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileResolveLink(linkpath, &canonicalpath) < 0) {
|
if (virFileResolveLink(linkpath, &canonicalpath) < 0) {
|
||||||
virReportSystemError(errno, _("failed to resolve '%s'"), linkpath);
|
virReportSystemError(errno, _("failed to resolve '%s'"), linkpath);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->type = g_path_get_basename(canonicalpath);
|
data->type = g_path_get_basename(canonicalpath);
|
||||||
|
|
||||||
data->uuid = g_strdup(udev_device_get_sysname(dev));
|
data->uuid = g_strdup(udev_device_get_sysname(dev));
|
||||||
if ((iommugrp = virMediatedDeviceGetIOMMUGroupNum(data->uuid)) < 0)
|
if ((iommugrp = virMediatedDeviceGetIOMMUGroupNum(data->uuid)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* lookup the address of parent device */
|
/* lookup the address of parent device */
|
||||||
parent_device = udev_device_get_parent(dev);
|
parent_device = udev_device_get_parent(dev);
|
||||||
@ -1072,11 +1071,7 @@ udevProcessMediatedDevice(struct udev_device *dev,
|
|||||||
|
|
||||||
data->iommuGroupNumber = iommugrp;
|
data->iommuGroupNumber = iommugrp;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(linkpath);
|
|
||||||
VIR_FREE(canonicalpath);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user