sensorhandler: Fix failed to obtain sensor threshold

If the getSensorThresholds method is called and the threshold fails
to be obtained, resp should not be updated to sensorThresholdMap,
otherwise this sensor will never be able to obtain the threshold.

This commit intends to update resp to sensorThresholdMap only when
the getSensorThresholds method is successfully called.

Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: Ia944879f0c19f744ae9b2be3aa7f4c7f73c3e5bb
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index dc0d85c..cd25da1 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -809,7 +809,12 @@
     auto it = sensorThresholdMap.find(sensorNum);
     if (it == sensorThresholdMap.end())
     {
-        sensorThresholdMap[sensorNum] = getSensorThresholds(ctx, sensorNum);
+        auto resp = getSensorThresholds(ctx, sensorNum);
+        if (resp.validMask == 0)
+        {
+            return ipmi::responseSensorInvalid();
+        }
+        sensorThresholdMap[sensorNum] = std::move(resp);
     }
 
     const auto& resp = sensorThresholdMap[sensorNum];