Skip to content

Commit 0070e73

Browse files
lenormandfranckgregkh
authored andcommitted
firmware: imx: scu: Fix corruption of header
[ Upstream commit f5f27b7 ] The header of the message to send can be changed if the response is longer than the request: - 1st word, the header is sent - the remaining words of the message are sent - the response is received asynchronously during the execution of the loop, changing the size field in the header - the for loop test the termination condition using the corrupted header It is the case for the API build_info which has just a header as request but 3 words in response. This issue is fixed storing the header locally instead of using a pointer on it. Fixes: edbee09 (firmware: imx: add SCU firmware driver support) Signed-off-by: Franck LENORMAND <[email protected]> Reviewed-by: Leonard Crestez <[email protected]> Signed-off-by: Leonard Crestez <[email protected]> Cc: [email protected] Reviewed-by: Dong Aisheng <[email protected]> Signed-off-by: Shawn Guo <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent a1fd068 commit 0070e73

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/firmware/imx/imx-scu.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,21 @@ static void imx_scu_rx_callback(struct mbox_client *c, void *msg)
158158

159159
static int imx_scu_ipc_write(struct imx_sc_ipc *sc_ipc, void *msg)
160160
{
161-
struct imx_sc_rpc_msg *hdr = msg;
161+
struct imx_sc_rpc_msg hdr = *(struct imx_sc_rpc_msg *)msg;
162162
struct imx_sc_chan *sc_chan;
163163
u32 *data = msg;
164164
int ret;
165165
int size;
166166
int i;
167167

168168
/* Check size */
169-
if (hdr->size > IMX_SC_RPC_MAX_MSG)
169+
if (hdr.size > IMX_SC_RPC_MAX_MSG)
170170
return -EINVAL;
171171

172-
dev_dbg(sc_ipc->dev, "RPC SVC %u FUNC %u SIZE %u\n", hdr->svc,
173-
hdr->func, hdr->size);
172+
dev_dbg(sc_ipc->dev, "RPC SVC %u FUNC %u SIZE %u\n", hdr.svc,
173+
hdr.func, hdr.size);
174174

175-
size = sc_ipc->fast_ipc ? 1 : hdr->size;
175+
size = sc_ipc->fast_ipc ? 1 : hdr.size;
176176
for (i = 0; i < size; i++) {
177177
sc_chan = &sc_ipc->chans[i % 4];
178178

0 commit comments

Comments
 (0)