VOL-3637: Protect concurrent access to deviceHandlersCreateChan

Change-Id: I0d4b06b75daaf8225ceb4b9e55890e852812fad0
diff --git a/VERSION b/VERSION
index 1713aea..8f2d7a5 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.13-dev138
+0.1.13-dev139
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/onuadaptercore/openonu.go
index cdce427..eeeb437 100644
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/onuadaptercore/openonu.go
@@ -152,6 +152,7 @@
 		if _, exist := oo.deviceHandlersCreateChan[deviceID]; !exist {
 			oo.deviceHandlersCreateChan[deviceID] = make(chan bool, 1)
 		}
+		deviceCreateChan := oo.deviceHandlersCreateChan[deviceID]
 		//keep the read sema short to allow for subsequent write
 		oo.lockDeviceHandlersMap.Unlock()
 		// based on concurrent processing the deviceHandler creation may not yet be finished at his point
@@ -160,9 +161,10 @@
 		case <-time.After(1 * time.Second): //timer may be discussed ...
 			logger.Warnw("No valid deviceHandler created after max WaitTime", log.Fields{"device-id": deviceID})
 			return nil
-		case <-oo.deviceHandlersCreateChan[deviceID]:
+		case <-deviceCreateChan:
 			logger.Debugw("deviceHandler is ready now - continue", log.Fields{"device-id": deviceID})
-			// if written now, we can return the written value without sema
+			oo.lockDeviceHandlersMap.RLock()
+			defer oo.lockDeviceHandlersMap.RUnlock()
 			return oo.deviceHandlers[deviceID]
 		}
 	}