Merge cherrypicks of [13326748, 13326765, 13326751, 13326753, 13326806, 13326807, 13326446, 13326845, 13326865, 13326885, 13326467, 13326686, 13326726, 13326905, 13326925, 13326945, 13326965, 13326966, 13326808, 13326809, 13326786, 13326766] into pi-wear-hmr1-dr-halibut-release

Change-Id: I09d868a6838c44f8fb2ff95571b43e5076281335
diff --git a/basicmbr.cc b/basicmbr.cc
index 23f35b4..81e42ca 100644
--- a/basicmbr.cc
+++ b/basicmbr.cc
@@ -260,7 +260,8 @@
          if (EbrLocations[i] == offset) { // already read this one; infinite logical partition loop!
             cerr << "Logical partition infinite loop detected! This is being corrected.\n";
             allOK = -1;
-            partNum -= 1;
+            if(partNum > 0) //don't go negative
+                partNum -= 1;
          } // if
       } // for
       EbrLocations[partNum] = offset;