]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print: fix segfault in supported-log-pages json output
authorMartin George <marting@netapp.com>
Tue, 7 Mar 2023 11:09:54 +0000 (16:39 +0530)
committerDaniel Wagner <wagi@monom.org>
Tue, 7 Mar 2023 13:17:36 +0000 (14:17 +0100)
nvme supported-log-pages -o json currently segfaults due to the
wrong json object type as shown below:

nvme: json_object.c: json_object_array_add: Assertion `json_object_get_type(jso) == json_type_array' failed.
Aborted (core dumped)

Fix this by passing the appropriate json type.

Signed-off-by: Martin George <marting@netapp.com>
nvme-print-json.c

index 176c55572de7ec2617d3efdd161a29fe4350b509..40dbb2f8f2d21bdc32408734f65c0145c8565a94 100644 (file)
@@ -2441,7 +2441,7 @@ void json_support_log(struct nvme_supported_log_pages *support_log)
        __u32 support;
 
        root = json_create_object();
-       valid = json_create_object();
+       valid = json_create_array();
 
        for (lid = 0; lid < 256; lid++) {
                support = le32_to_cpu(support_log->lid_support[lid]);