]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
nbft: Fix (struct nbft_info_subsystem_ns).num_hfis off-by-one
authorTomas Bzatek <tbzatek@redhat.com>
Fri, 5 Jan 2024 13:42:11 +0000 (14:42 +0100)
committerDaniel Wagner <wagi@monom.org>
Mon, 5 Feb 2024 09:35:32 +0000 (10:35 +0100)
The num_hfis field only reflected the number of Secondary HFI
Associations, resulting in the last parsed HFI being ignored
by users (nvme-cli).

According to the NVM Express Boot Specification, Revision 1.0,
the Primary HFI Descriptor Index in the Subsystem Namespace
(SSNS) Descriptor contains this note:

  "If multiple HFIs are associated with this record, subsequent
   interfaces should be populated in the Secondary HFI
   Associations field."

As both the primary and secondary HFIs are parsed into a single
array, it makes sense to reflect the proper number of elements.

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
src/nvme/nbft.c

index 2c87088028dad9fe1bdc7e9633113d38ebc39481..06632323c2a9f826dca07ff2079b370811abeae2 100644 (file)
@@ -274,6 +274,7 @@ static int read_ssns(struct nbft_info *nbft,
                ret = -EINVAL;
                goto fail;
        }
+       ssns->num_hfis = 1;
        for (i = 0; i < le16_to_cpu(raw_ssns->secondary_hfi_assoc_obj.length); i++) {
                ssns->hfis[i + 1] = hfi_from_index(nbft, ss_hfi_indexes[i]);
                if (ss_hfi_indexes[i] && !ssns->hfis[i + 1])