From 332893acfa5f0e51aeca43b9e4151c960220caab Mon Sep 17 00:00:00 2001 From: Martin George Date: Mon, 21 Feb 2022 15:47:24 +0530 Subject: [PATCH] nvme-print: fix 'nvme list -o json' segfault After the recent upgrade to libnvme, 'nvme list -o json' segfaults due to incorrect json object type passed here. So fix this by passing the appropriate json object type and invoking it outside the nvme_for_each_host loop. Signed-off-by: Martin George --- nvme-print.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvme-print.c b/nvme-print.c index bad0da13..d1aef1a3 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -7206,8 +7206,8 @@ static void json_simple_list(nvme_root_t r) json_array_add_value_object(jdevices, json_list_item(n)); } - json_object_add_value_object(jroot, "devices", jdevices); } + json_object_add_value_array(jroot, "devices", jdevices); json_print_object(jroot, NULL); printf("\n"); json_free_object(jroot); -- 2.50.1