From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Richard Fitzgerald <rf@opensource.cirrus.com>,
vkoul@kernel.org, yung-chuan.liao@linux.intel.com,
sanyog.r.kale@intel.com
Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] soundwire: cadence: Don't overwrite msg->buf during write commands
Date: Fri, 16 Sep 2022 12:55:31 +0200 [thread overview]
Message-ID: <0f4154f6-ad5a-22e7-3b95-5a577c1dff47@linux.intel.com> (raw)
In-Reply-To: <20220916103505.1562210-1-rf@opensource.cirrus.com>
On 9/16/22 12:35, Richard Fitzgerald wrote:
> 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>
> ---
> drivers/soundwire/cadence_master.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
> index be9cd47f31ec..3ef472049980 100644
> --- a/drivers/soundwire/cadence_master.c
> +++ b/drivers/soundwire/cadence_master.c
> @@ -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;
> }
next prev parent reply other threads:[~2022-09-16 11:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 10:35 [PATCH] soundwire: cadence: Don't overwrite msg->buf during write commands Richard Fitzgerald
2022-09-16 10:55 ` Pierre-Louis Bossart [this message]
2022-09-20 5:00 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f4154f6-ad5a-22e7-3b95-5a577c1dff47@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rf@opensource.cirrus.com \
--cc=sanyog.r.kale@intel.com \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox