[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] tools/libs/light: Fix nic->vlan memory allocation
commit 74970165bab8924898f3ad186364bf96310e8e4e Author: Leigh Brown <leigh@xxxxxxxxxxxxx> AuthorDate: Thu Jun 20 12:09:02 2024 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Jun 20 12:09:02 2024 +0200 tools/libs/light: Fix nic->vlan memory allocation After the following commit: 3bc14e4fa4b9 ("tools/libs/light: Add vlan field to libxl_device_nic") xl list -l aborts with a double free error if a domain has at least one vif defined: $ sudo xl list -l free(): double free detected in tcache 2 Aborted Orginally, the vlan field was called vid and was defined as an integer. It was appropriate to call libxl__xs_read_checked() with gc passed as the string data was copied to a different variable. However, the final version uses a string data type and the call should have been changed to use NOGC instead of gc to allow that data to live past the gc controlled lifetime, in line with the other string fields. This patch makes the change to pass NOGC instead of gc and moves the new code to be next to the other string fields (fixing a couple of errant tabs along the way), as recommended by Jason. Fixes: 3bc14e4fa4b9 ("tools/libs/light: Add vlan field to libxl_device_nic") Signed-off-by: Leigh Brown <leigh@xxxxxxxxxxxxx> Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx> Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Release-acked-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx> --- tools/libs/light/libxl_nic.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/libs/light/libxl_nic.c b/tools/libs/light/libxl_nic.c index d861e3726d..300a96a8b1 100644 --- a/tools/libs/light/libxl_nic.c +++ b/tools/libs/light/libxl_nic.c @@ -318,11 +318,6 @@ static int libxl__nic_from_xenstore(libxl__gc *gc, const char *libxl_path, nic->mtu = LIBXL_DEVICE_NIC_MTU_DEFAULT; } - rc = libxl__xs_read_checked(gc, XBT_NULL, - GCSPRINTF("%s/vlan", libxl_path), - (const char **)(&nic->vlan)); - if (rc) goto out; - rc = libxl__xs_read_checked(gc, XBT_NULL, GCSPRINTF("%s/mac", libxl_path), &tmp); if (rc) goto out; @@ -345,6 +340,10 @@ static int libxl__nic_from_xenstore(libxl__gc *gc, const char *libxl_path, GCSPRINTF("%s/script", libxl_path), (const char **)(&nic->script)); if (rc) goto out; + rc = libxl__xs_read_checked(NOGC, XBT_NULL, + GCSPRINTF("%s/vlan", libxl_path), + (const char **)(&nic->vlan)); + if (rc) goto out; rc = libxl__xs_read_checked(NOGC, XBT_NULL, GCSPRINTF("%s/forwarddev", libxl_path), (const char **)(&nic->coloft_forwarddev)); -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |