libpldm: Fix logical errors between length check and cc decoding

When calling the encode_xxx_resp method in the registration method of
libpldmresponder, if the return value isn't PLDM_SUCCESS, the
payload_length value is only 1(return ccOnlyResponse method) and not a
complete responder data length, so we must first check cc in the
decode_xxx_resp method to avoid logic errors.

if cc != PLDM_SUCCESS, return PLDM_SUCCESS and don't need check
payload_length.
if cc == PLDM_SUCCESS, then check payload_length.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Iaf27c3a6b45638375a4ad1542dd5c4067bbd67b1
diff --git a/libpldm/platform.c b/libpldm/platform.c
index 8b9506f..1eb4656 100644
--- a/libpldm/platform.c
+++ b/libpldm/platform.c
@@ -63,12 +63,15 @@
 		return PLDM_ERROR_INVALID_DATA;
 	}
 
+	*completion_code = msg->payload[0];
+	if (PLDM_SUCCESS != *completion_code) {
+		return PLDM_SUCCESS;
+	}
+
 	if (payload_length > PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES) {
 		return PLDM_ERROR_INVALID_LENGTH;
 	}
 
-	*completion_code = msg->payload[0];
-
 	return PLDM_SUCCESS;
 }
 
@@ -220,7 +223,7 @@
 
 	*completion_code = msg->payload[0];
 	if (PLDM_SUCCESS != *completion_code) {
-		return *completion_code;
+		return PLDM_SUCCESS;
 	}
 
 	if (payload_length < PLDM_GET_PDR_MIN_RESP_BYTES) {