firmware: imx: scu: Fix corruption of header
authorFranck LENORMAND <franck.lenormand@nxp.com>
Wed, 25 Mar 2020 22:00:05 +0000 (00:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jun 2020 14:42:01 +0000 (16:42 +0200)
commitcf39fe5340fc377fa57f828403e56a746c7a0583
tree28570a1da681d8417c3777e8b3f404bbd63e1571
parent29c4ccc6fb1533178e7ca8e80ca13b6cae7a7757
firmware: imx: scu: Fix corruption of header

[ Upstream commit f5f27b79eab80de0287c243a22169e4876b08d5e ]

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: edbee095fafb (firmware: imx: add SCU firmware driver support)
Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Cc: stable@vger.kernel.org
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/imx/imx-scu.c