requester: Fix response buffer cast in pldm_send_recv()
With the latest libpldm code version 0.4, sometimes the calling
`pldmtool platform GetPDR` command while polling the sensors will be
ended with the errors `Failed to receive RC = 3`. This error code is
printed when the `pldm_send_recv()` responses
PLDM_REQUESTER_NOT_RESP_MSG.
In the `pldm_send_recv()`, `hdr` is `struct pldm_msg_hdr` pointer and
`pldm_resp_msg` is a double pointer, type casting the double pointer to
the pointer is incorrect.
Tested:
1. Call `pldmtool platform GetPDR` command while running the sensor
reading.
2. No `Failed to receive RC = 3`
Fixes: 0411b712b746 ("transport: Make APIs work for all types of messages")
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I1efadc80bbd8803d0b97cb634eb8bd7df9d279b9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48cdc46..d52a424 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,10 @@
## [Unreleased]
+### Fixed
+
+1. requester: Fix response buffer cast in pldm_send_recv()
+
## [0.4.0] - 2023-07-14
### Added
diff --git a/src/requester/pldm.c b/src/requester/pldm.c
index 0c28b31..7865cfe 100644
--- a/src/requester/pldm.c
+++ b/src/requester/pldm.c
@@ -153,7 +153,7 @@
if (rc != PLDM_REQUESTER_SUCCESS) {
return rc;
}
- hdr = (struct pldm_msg_hdr *)pldm_resp_msg;
+ hdr = (struct pldm_msg_hdr *)(*pldm_resp_msg);
if (hdr && (hdr->request || hdr->datagram)) {
free(*pldm_resp_msg);
*pldm_resp_msg = NULL;