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/fru.h b/libpldm/fru.h
index 2b5dd9f..6a14956 100644
--- a/libpldm/fru.h
+++ b/libpldm/fru.h
@@ -138,6 +138,12 @@
/** @brief Decode GetFruRecordTable response data
*
+ * Note:
+ * * If the return value is not PLDM_SUCCESS, it represents a
+ * transport layer error.
+ * * If the completion_code value is not PLDM_SUCCESS, it represents a
+ * protocol layer error and all the out-parameters are invalid.
+ *
* @param[in] msg - Response message
* @param[in] payload_length - Length of response message payload
* @param[out] completion_code - Pointer to response msg's PLDM completion code