VOL-3941 : Fix nil pointer access
- the pLastTxMeInstance is nil when LockStateFsm has reset.
  We should ignore any OMCI SET Response Msg in this case.

Change-Id: I4ece6a893016c589687da1825bf872987882b0c0
diff --git a/internal/pkg/onuadaptercore/uniportadmin.go b/internal/pkg/onuadaptercore/uniportadmin.go
index 4f060a2..6fa69fb 100644
--- a/internal/pkg/onuadaptercore/uniportadmin.go
+++ b/internal/pkg/onuadaptercore/uniportadmin.go
@@ -316,29 +316,35 @@
 			// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
 			return
 		}
-		// compare comments above for CreateResponse (apply also here ...)
-		if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() &&
-			msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() {
-			//store the created ME into DB //TODO??? obviously the Python code does not store the config ...
-			// if, then something like:
-			//oFsm.pOnuDB.StoreMe(msgObj)
 
-			switch oFsm.pLastTxMeInstance.GetName() {
-			case "OnuG":
-				{ // let the FSM proceed ...
-					_ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxOnugResp)
+		if oFsm.pLastTxMeInstance != nil {
+			// compare comments above for CreateResponse (apply also here ...)
+			if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() &&
+				msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() {
+				//store the created ME into DB //TODO??? obviously the Python code does not store the config ...
+				// if, then something like:
+				//oFsm.pOnuDB.StoreMe(msgObj)
+
+				switch oFsm.pLastTxMeInstance.GetName() {
+				case "OnuG":
+					{ // let the FSM proceed ...
+						_ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxOnugResp)
+					}
+				case "PhysicalPathTerminationPointEthernetUni", "VirtualEthernetInterfacePoint":
+					{ // let the PPTP init proceed by stopping the wait function
+						oFsm.omciLockResponseReceived <- true
+					}
 				}
-			case "PhysicalPathTerminationPointEthernetUni", "VirtualEthernetInterfacePoint":
-				{ // let the PPTP init proceed by stopping the wait function
-					oFsm.omciLockResponseReceived <- true
-				}
+			} else {
+				logger.Warnf(ctx, "LockStateFsm - Received SetResponse Data for %s with wrong classID or entityID ",
+					log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj}, msgObj.EntityClass)
 			}
 		} else {
-			logger.Warnf(ctx, "LockStateFsm - Received SetResponse Data for %s with wrong classID or entityID ",
-				log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj}, msgObj.EntityClass)
+			logger.Errorw(ctx, "LockStateFsm - Rx OMCI unhandled MsgType", log.Fields{"omciMsgType": msg.OmciMsg.MessageType})
+			return
 		}
 	} else {
-		logger.Errorw(ctx, "LockStateFsm - Rx OMCI unhandled MsgType", log.Fields{"omciMsgType": msg.OmciMsg.MessageType})
+		logger.Warnw(ctx, "pLastTxMeInstance is nil, possibly the pLastTxMeInstance has already reset", log.Fields{"device-id": oFsm.deviceID})
 		return
 	}
 }