Commit d0193c6d6716 introduced checking for the return value of
printf_info_one_json(), but failed to remove a further check down, which
now Coverity complains is dead code.
The correct fix is to make the call to json_object_array_add() conditional
on printf_info_one_json() having been successful, so that the further call
to libxl_domain_config_dispose() is not avoided.
CID: 1667251
Fixes: d0193c6d6716 ("tools/xl: check return value of printf_info_one_json() in list_domains_details()")
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
As with previous fixes, needs to be considered for 4.21.
---
tools/xl/xl_info.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c
index dbb682cc52a6..98fc879e636c 100644
--- a/tools/xl/xl_info.c
+++ b/tools/xl/xl_info.c
@@ -584,9 +584,8 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain)
#ifdef HAVE_LIBJSONC
json_object *jso_value;
rc = printf_info_one_json(&jso_value, info[i].domid, &d_config);
- if (rc)
- goto out;
- json_object_array_add(jso, jso_value);
+ if (!rc)
+ json_object_array_add(jso, jso_value);
#elif defined(HAVE_LIBYAJL)
s = printf_info_one_json(hand, info[i].domid, &d_config);
#endif
--
2.51.0
On Mon, Oct 20, 2025 at 01:19:59PM +0100, Roger Pau Monne wrote:
> Commit d0193c6d6716 introduced checking for the return value of
> printf_info_one_json(), but failed to remove a further check down, which
> now Coverity complains is dead code.
>
> The correct fix is to make the call to json_object_array_add() conditional
> on printf_info_one_json() having been successful, so that the further call
> to libxl_domain_config_dispose() is not avoided.
>
> CID: 1667251
> Fixes: d0193c6d6716 ("tools/xl: check return value of printf_info_one_json() in list_domains_details()")
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
Thanks,
--
Anthony PERARD
On 10/20/25 2:19 PM, Roger Pau Monne wrote:
> Commit d0193c6d6716 introduced checking for the return value of
> printf_info_one_json(), but failed to remove a further check down, which
> now Coverity complains is dead code.
>
> The correct fix is to make the call to json_object_array_add() conditional
> on printf_info_one_json() having been successful, so that the further call
> to libxl_domain_config_dispose() is not avoided.
>
> CID: 1667251
> Fixes: d0193c6d6716 ("tools/xl: check return value of printf_info_one_json() in list_domains_details()")
> Signed-off-by: Roger Pau Monné<roger.pau@citrix.com>
> ---
> As with previous fixes, needs to be considered for 4.21.
Release-Acked-By: Oleksii Kurochko<oleksii.kurochko@gmail.com>
Thanks.
~ Oleksii
> ---
> tools/xl/xl_info.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c
> index dbb682cc52a6..98fc879e636c 100644
> --- a/tools/xl/xl_info.c
> +++ b/tools/xl/xl_info.c
> @@ -584,9 +584,8 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain)
> #ifdef HAVE_LIBJSONC
> json_object *jso_value;
> rc = printf_info_one_json(&jso_value, info[i].domid, &d_config);
> - if (rc)
> - goto out;
> - json_object_array_add(jso, jso_value);
> + if (!rc)
> + json_object_array_add(jso, jso_value);
> #elif defined(HAVE_LIBYAJL)
> s = printf_info_one_json(hand, info[i].domid, &d_config);
> #endif
© 2016 - 2025 Red Hat, Inc.