summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.cirrus.com>2022-09-16 11:35:05 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-10-26 13:25:53 +0200
commitf04a673d4a27438d19b08a4d2842c5426b1cbeb5 (patch)
tree37c6d8d1f4152e4187cf205c551284a07b0add74
parentc263516c2c20df9c29f33baeb4a817af7212fb69 (diff)
downloadlinux-stable-f04a673d4a27438d19b08a4d2842c5426b1cbeb5.tar.gz
linux-stable-f04a673d4a27438d19b08a4d2842c5426b1cbeb5.tar.bz2
linux-stable-f04a673d4a27438d19b08a4d2842c5426b1cbeb5.zip
soundwire: cadence: Don't overwrite msg->buf during write commands
[ Upstream commit ba05b39d265bdd16913f7684600d9d41e2796745 ] The buf passed in struct sdw_msg must only be written for a READ, in that case the RDATA part of the response is the data value of the register. For a write command there is no RDATA, and buf should be assumed to be const and unmodifable. The original caller should not expect its data buffer to be corrupted by an sdw_nwrite(). Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20220916103505.1562210-1-rf@opensource.cirrus.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/soundwire/cadence_master.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
index c6d421a4b91b..a3247692ddc0 100644
--- a/drivers/soundwire/cadence_master.c
+++ b/drivers/soundwire/cadence_master.c
@@ -501,9 +501,12 @@ cdns_fill_msg_resp(struct sdw_cdns *cdns,
return SDW_CMD_IGNORED;
}
- /* fill response */
- for (i = 0; i < count; i++)
- msg->buf[i + offset] = FIELD_GET(CDNS_MCP_RESP_RDATA, cdns->response_buf[i]);
+ if (msg->flags == SDW_MSG_FLAG_READ) {
+ /* fill response */
+ for (i = 0; i < count; i++)
+ msg->buf[i + offset] = FIELD_GET(CDNS_MCP_RESP_RDATA,
+ cdns->response_buf[i]);
+ }
return SDW_CMD_OK;
}