diff mbox

[ndctl] ndctl, init-labels: fix label initialization to use valid seq numbers

Message ID 150646599811.6110.8609223703710925670.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit 3795335057ff
Headers show

Commit Message

Dan Williams Sept. 26, 2017, 10:46 p.m. UTC
The set of valid sequence numbers is {1,2,3}. The specification
indicates that an implementation should consider 0 a sign of a critical
error:

    UEFI 2.7: 13.19 NVDIMM Label Protocol

    Software never writes the sequence number 00, so a correctly
    check-summed Index Block with this sequence number probably indicates a
    critical error. When software discovers this case it treats it as an
    invalid Index Block indication.

While the expectation is that the invalid block is just thrown away, the
Robustness Principle says we should fix this to make both sequence
numbers valid.

Fixes: 681f5d786e94 ("ndctl: init-labels command")
Reported-by: Juston Li <juston.li@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/lib/dimm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/ndctl/lib/dimm.c b/ndctl/lib/dimm.c
index 794a4f4469c9..b3e032e04088 100644
--- a/ndctl/lib/dimm.c
+++ b/ndctl/lib/dimm.c
@@ -452,7 +452,7 @@  NDCTL_EXPORT int ndctl_dimm_init_labels(struct ndctl_dimm *dimm,
 	for (i = 0; i < 2; i++) {
 		int rc;
 
-		rc = write_label_index(dimm, v, i, i*2);
+		rc = write_label_index(dimm, v, i, 3 - i);
 		if (rc < 0)
 			return rc;
 	}