Skip to content

Commit 09f4577

Browse files
mwilckigaw
authored andcommitted
nbft: avoid duplicate entries in ssns->hfis
The NVMe boot specification does not disallow listing the primary HFI index again in the secondary HFI list, or listing the same index multiple times in the secondary HFI list. But such duplicate entries aren't helpful for consumers of this data. In the worst case, they might lead to confusion and misconfiguration. Suppress them. Signed-off-by: Martin Wilck <[email protected]>
1 parent 220e887 commit 09f4577

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/nvme/nbft.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,27 @@ static int read_ssns(struct nbft_info *nbft,
276276
}
277277
ssns->num_hfis = 1;
278278
for (i = 0; i < le16_to_cpu(raw_ssns->secondary_hfi_assoc_obj.length); i++) {
279+
bool duplicate = false;
280+
int j;
281+
282+
for (j = 0; j < i; j++) {
283+
if (ss_hfi_indexes[i] == ss_hfi_indexes[j]) {
284+
duplicate = true;
285+
break;
286+
}
287+
}
288+
289+
if (!duplicate &&
290+
ss_hfi_indexes[i] == raw_ssns->primary_hfi_desc_index)
291+
duplicate = true;
292+
293+
if (duplicate) {
294+
nvme_msg(NULL, LOG_DEBUG,
295+
"file %s: SSNS %d skipping duplicate HFI index %d\n",
296+
nbft->filename, ssns->index, ss_hfi_indexes[i]);
297+
continue;
298+
}
299+
279300
ssns->hfis[i + 1] = hfi_from_index(nbft, ss_hfi_indexes[i]);
280301
if (ss_hfi_indexes[i] && !ssns->hfis[i + 1])
281302
nvme_msg(NULL, LOG_DEBUG,

0 commit comments

Comments
 (0)