mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
soundwire: cadence: Don't overwrite msg->buf during write commands
[ Upstream commit ba05b39d26
]
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>
This commit is contained in:
parent
d23765aca1
commit
4600500dff
1 changed files with 6 additions and 3 deletions
|
@ -544,9 +544,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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue