* [PATCH] xl: properly dispose of libxl_dominfo struct instances
@ 2025-01-14 8:12 Jan Beulich
2025-01-14 9:27 ` Andrew Cooper
2025-01-14 11:22 ` Oleksii Kurochko
0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2025-01-14 8:12 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org; +Cc: Anthony PERARD, Oleksii Kurochko
The ssid_label field requires separate freeing; make sure to call
libxl_dominfo_dispose(). And then, for good measure, also
libxl_dominfo_init().
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@suse.com>
---
I wasn't quite sure about use of libxl_dominfo_init(): vcpuset(), for
example, doesn't call it.
--- a/tools/xl/xl_sxp.c
+++ b/tools/xl/xl_sxp.c
@@ -45,8 +45,10 @@ void printf_info_sexp(int domid, libxl_d
/* 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");
}
--- 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) {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xl: properly dispose of libxl_dominfo struct instances
2025-01-14 8:12 [PATCH] xl: properly dispose of libxl_dominfo struct instances Jan Beulich
@ 2025-01-14 9:27 ` Andrew Cooper
2025-01-14 11:22 ` Oleksii Kurochko
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2025-01-14 9:27 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: Anthony PERARD, Oleksii Kurochko
On 14/01/2025 8:12 am, Jan Beulich wrote:
> The ssid_label field requires separate freeing; make sure to call
> libxl_dominfo_dispose(). And then, for good measure, also
> libxl_dominfo_init().
>
> 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@suse.com>
> ---
> I wasn't quite sure about use of libxl_dominfo_init(): vcpuset(), for
> example, doesn't call it.
It's a written requirement (somewhere) that *_init() and *_dispose() do
get called.
Except everyone's lazy with them and plenty of scenarios function
without, which is why it's often Coverity telling us about it (but only
for the instances where there's a real malloc()/free() gone missing).
I expect it would be better to extend this patch to fix up vcpuset()
too. The changes so far LGTM.
~Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xl: properly dispose of libxl_dominfo struct instances
2025-01-14 8:12 [PATCH] xl: properly dispose of libxl_dominfo struct instances Jan Beulich
2025-01-14 9:27 ` Andrew Cooper
@ 2025-01-14 11:22 ` Oleksii Kurochko
1 sibling, 0 replies; 3+ messages in thread
From: Oleksii Kurochko @ 2025-01-14 11:22 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org; +Cc: Anthony PERARD
[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]
On 1/14/25 9:12 AM, Jan Beulich wrote:
> The ssid_label field requires separate freeing; make sure to call
> libxl_dominfo_dispose(). And then, for good measure, also
> libxl_dominfo_init().
>
> 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@suse.com>
Release-Acked-by: Oleksii Kurochko<oleksii.kurochko@gmail.com>
Thanks.
~ Oleksii
> ---
> I wasn't quite sure about use of libxl_dominfo_init(): vcpuset(), for
> example, doesn't call it.
>
> --- a/tools/xl/xl_sxp.c
> +++ b/tools/xl/xl_sxp.c
> @@ -45,8 +45,10 @@ void printf_info_sexp(int domid, libxl_d
> /* 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");
> }
> --- 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) {
[-- Attachment #2: Type: text/html, Size: 2549 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-14 11:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-14 8:12 [PATCH] xl: properly dispose of libxl_dominfo struct instances Jan Beulich
2025-01-14 9:27 ` Andrew Cooper
2025-01-14 11:22 ` Oleksii Kurochko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.