[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH for-4.21 3/6] tools/xl: check return of json_object_object_add()
Check the return codes of json_object_object_add() calls in printf_info_one_json(). Reported by XenServer internal Coverity instance. Fixes: f6c6f2679d49 ("libxl: Convert libxl__object_to_json() to json-c") Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- tools/xl/xl_info.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index 777ff2c64294..2048669abbd4 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -69,7 +69,7 @@ static int printf_info_one_json(json_object **jso_r, int domid, json_object *jso_config = NULL; enum json_tokener_error error = json_tokener_success; char *s = NULL; - int r = EXIT_FAILURE; + int r = EXIT_FAILURE, rc; s = libxl_domain_config_to_json(ctx, d_config); jso_config = json_tokener_parse_verbose(s, &error); @@ -82,12 +82,17 @@ static int printf_info_one_json(json_object **jso_r, int domid, jso = json_object_new_object(); if (domid != -1) - json_object_object_add(jso, "domid", json_object_new_int(domid)); + rc = json_object_object_add(jso, "domid", json_object_new_int(domid)); else - json_object_object_add(jso, "domid", json_object_new_null()); + rc = json_object_object_add(jso, "domid", json_object_new_null()); + if (rc) + goto out; + + rc = json_object_object_add(jso, "config", jso_config); + if (rc) + goto out; - json_object_object_add(jso, "config", jso_config); jso_config = NULL; *jso_r = jso; -- 2.51.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |