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

[xen staging] xl: properly dispose of libxl_dominfo struct instances



commit 274c509162fe91ec97428e19be58b950af919184
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Jan 17 08:54:03 2025 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Jan 17 08:54:03 2025 +0100

    xl: properly dispose of libxl_dominfo struct instances
    
    The ssid_label field requires separate freeing; make sure to call
    libxl_dominfo_dispose() as well as libxl_dominfo_init(). Since vcpuset()
    calls only the former, add a call to the latter there at the same time.
    
    Coverity-ID: 1638727
    Coverity-ID: 1638728
    Fixes: c458c404da16 ("xl: use libxl_domain_info to get the uuid in 
printf_info")
    Fixes: 48dab9767d2e ("tools/xl: use libxl_domain_info to get domain type 
for vcpu-pin")
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
    Release-Acked-by: Oleksii Kurochko<oleksii.kurochko@xxxxxxxxx>
---
 tools/xl/xl_sxp.c  | 2 ++
 tools/xl/xl_vcpu.c | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/tools/xl/xl_sxp.c b/tools/xl/xl_sxp.c
index 359a001570..4383ad177a 100644
--- a/tools/xl/xl_sxp.c
+++ b/tools/xl/xl_sxp.c
@@ -45,8 +45,10 @@ void printf_info_sexp(int domid, libxl_domain_config 
*d_config, FILE *fh)
     /* retrieve the UUID from dominfo, since it is probably generated
      * during parsing and thus does not match the real one
      */
+    libxl_dominfo_init(&info);
     if (libxl_domain_info(ctx, &info, domid) == 0) {
         fprintf(fh, "\t(uuid " LIBXL_UUID_FMT ")\n", 
LIBXL_UUID_BYTES(info.uuid));
+        libxl_dominfo_dispose(&info);
     } else {
         fprintf(fh, "\t(uuid <unknown>)\n");
     }
diff --git a/tools/xl/xl_vcpu.c b/tools/xl/xl_vcpu.c
index 66877a57de..b7dbc3e842 100644
--- a/tools/xl/xl_vcpu.c
+++ b/tools/xl/xl_vcpu.c
@@ -286,6 +286,8 @@ int main_vcpupin(int argc, char **argv)
     if (!ignore_masks && hard) {
         libxl_dominfo dominfo;
 
+        libxl_dominfo_init(&dominfo);
+
         if (libxl_domain_info(ctx, &dominfo, domid)) {
             fprintf(stderr, "Could not get domain info\n");
             goto out;
@@ -293,6 +295,8 @@ int main_vcpupin(int argc, char **argv)
 
         /* HVM and PVH domains use the same global affinity mask */
         apply_global_affinity_masks(dominfo.domain_type, hard, 1);
+
+        libxl_dominfo_dispose(&dominfo);
     }
 
     if (force) {
@@ -348,6 +352,7 @@ static int vcpuset(uint32_t domid, const char* nr_vcpus, 
int check_host)
         unsigned int online_vcpus, host_cpu = libxl_get_max_cpus(ctx);
         libxl_dominfo dominfo;
 
+        libxl_dominfo_init(&dominfo);
         if (libxl_domain_info(ctx, &dominfo, domid))
             return 1;
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.