All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-4.21] tools/xl: fix for dead code in list_domains_details()
@ 2025-10-20 12:19 Roger Pau Monne
  2025-10-20 15:55 ` Oleksii Kurochko
  2025-10-21  9:57 ` Anthony PERARD
  0 siblings, 2 replies; 3+ messages in thread
From: Roger Pau Monne @ 2025-10-20 12:19 UTC (permalink / raw)
  To: xen-devel; +Cc: oleksii.kurochko, Roger Pau Monne, Anthony PERARD

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-4.21] tools/xl: fix for dead code in list_domains_details()
  2025-10-20 12:19 [PATCH for-4.21] tools/xl: fix for dead code in list_domains_details() Roger Pau Monne
@ 2025-10-20 15:55 ` Oleksii Kurochko
  2025-10-21  9:57 ` Anthony PERARD
  1 sibling, 0 replies; 3+ messages in thread
From: Oleksii Kurochko @ 2025-10-20 15:55 UTC (permalink / raw)
  To: Roger Pau Monne, xen-devel; +Cc: Anthony PERARD

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]


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

[-- Attachment #2: Type: text/html, Size: 2199 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-4.21] tools/xl: fix for dead code in list_domains_details()
  2025-10-20 12:19 [PATCH for-4.21] tools/xl: fix for dead code in list_domains_details() Roger Pau Monne
  2025-10-20 15:55 ` Oleksii Kurochko
@ 2025-10-21  9:57 ` Anthony PERARD
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony PERARD @ 2025-10-21  9:57 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, oleksii.kurochko, Anthony PERARD

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-21  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 12:19 [PATCH for-4.21] tools/xl: fix for dead code in list_domains_details() Roger Pau Monne
2025-10-20 15:55 ` Oleksii Kurochko
2025-10-21  9:57 ` Anthony PERARD

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.