From: sashiko-bot@kernel.org
To: "Ye Weihua" <yeweihua4@huawei.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v2 3/3] ASoC: SOF: ipc4-control: Rebuild replay message after restoring data
Date: Fri, 20 Nov 2026 07:42:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-224651@kernel.org> (raw)
In-Reply-To: <20261120070042.279508-4-yeweihua4@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: SOF: ipc4: missing size and type check in
sof_ipc4_set_get_bytes_data()
--
commit 5bb9387ebbc31097ff7ba75b9019b86b70c0a08a
Author: Ye Weihua <yeweihua4@huawei.com>
ASoC: SOF: ipc4-control: Rebuild replay message after restoring data
This commit moves the IPC replay after a rejected set-data request from
sof_ipc4_set_get_kcontrol_data() to its callers so that the message and
payload are rebuilt from the restored backup data.
> diff --git a/sound/soc/sof/ipc4-control.c b/sound/soc/sof/ipc4-control.c
> index ace3bf2f719d3..8ed006efe17f3 100644
> --- a/sound/soc/sof/ipc4-control.c
> +++ b/sound/soc/sof/ipc4-control.c
[ ... ]
> @@ -315,12 +314,35 @@ sof_ipc4_set_bytes_control_data(struct snd_sof_control *scontrol, bool lock)
> msg.data_size = data_size;
>
> ret = sof_ipc4_set_get_kcontrol_data(scontrol, &msg, true, lock);
> +
> + kfree(msg_data);
> +
> + return ret;
> +}
> +
> +static int
> +sof_ipc4_set_bytes_control_data(struct snd_sof_control *scontrol, bool lock)
> +{
> + struct snd_soc_component *scomp = scontrol->scomp;
> + void *old_ipc_control_data;
> + int ret;
> +
> + old_ipc_control_data = scontrol->old_ipc_control_data;
> + ret = sof_ipc4_send_bytes_control_data(scontrol, lock);
> + if (ret < 0 && old_ipc_control_data &&
> + !scontrol->old_ipc_control_data) {
> + /*
> + * The new data was rejected and the last known good
> + * configuration was restored. Rebuild the message from the
> + * restored control data and replay it.
> + */
> + ret = sof_ipc4_send_bytes_control_data(scontrol, lock);
> + }
> +
> if (ret < 0)
> dev_err(scomp->dev, "%s: Failed to set control update for %s\n",
> __func__, scontrol->name);
>
> - kfree(msg_data);
> -
> return ret;
> }
>
> @@ -510,6 +532,7 @@ static int sof_ipc4_set_get_bytes_data(struct snd_sof_dev *sdev,
> struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data;
> struct sof_abi_hdr *data = cdata->data;
> struct sof_ipc4_msg msg;
> + void *old_ipc_control_data;
> int ret = 0;
>
> /* Send the new data to the firmware only if it is powered up */
> @@ -540,7 +563,21 @@ static int sof_ipc4_set_get_bytes_data(struct snd_sof_dev *sdev,
> else
> msg.data_size = scontrol->max_size - sizeof(*data);
>
> + old_ipc_control_data = scontrol->old_ipc_control_data;
> ret = sof_ipc4_set_get_kcontrol_data(scontrol, &msg, set, lock);
> + if (ret < 0 && set && old_ipc_control_data &&
> + !scontrol->old_ipc_control_data) {
> + /*
> + * The new data was rejected and the last known good
> + * configuration was restored. Rebuild the message from the
> + * restored control data and replay it.
> + */
> + msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(data->type);
> + msg.data_ptr = data->data;
> + msg.data_size = data->size;
> + ret = sof_ipc4_set_get_kcontrol_data(scontrol, &msg, set, lock);
> + }
[Severity: Medium]
Does replaying inside sof_ipc4_set_bytes_control_data() and
sof_ipc4_set_get_bytes_data() skip the !data->size and data->type checks
that sof_ipc4_set_get_bytes_data() only performs before the first send?
When a bytes control is loaded from topology without initial data
(scontrol->priv_size == 0), sof_ipc4_bytes_ext_put() backs up the
zero-initialized cdata->data (data->size == 0, data->type == 0) into
scontrol->old_ipc_control_data. If the firmware rejects an update and
sof_ipc4_set_get_kcontrol_data() restores that empty backup, both replay
paths unconditionally send a 0-byte MOD_LARGE_CONFIG_SET IPC with
param_id 0 instead of returning early as the initial !data->size check
does. Likewise, if the rejected user payload and the restored backup
differ on whether data->type is SOF_IPC4_BYTES_CONTROL_PARAM_ID, the
replay stays in the branch chosen by the rejected data->type and sends
the restored payload in the wrong format.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120070042.279508-1-yeweihua4@huawei.com?part=3
prev parent reply other threads:[~2026-11-20 7:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:00 [PATCH v2 0/3] ASoC: SOF: ipc4-control: fix bytes control restore and replay Ye Weihua
2026-11-20 7:00 ` [PATCH v2 1/3] ASoC: SOF: ipc4-control: Fix out-of-bounds backup restore in bytes ext put Ye Weihua
2026-11-20 7:00 ` [PATCH v2 2/3] ASoC: SOF: topology: Free bytes control backup on unload Ye Weihua
2026-11-20 7:00 ` [PATCH v2 3/3] ASoC: SOF: ipc4-control: Rebuild replay message after restoring data Ye Weihua
2026-11-20 7:42 ` sashiko-bot [this message]
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=sashiko-outbox-224651@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yeweihua4@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.