From: sashiko-bot@kernel.org
To: "Riccardo Mereu" <r.mereu.kernel@arduino.cc>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] soc: qcom: apr: accept packets without payload
Date: Tue, 01 Dec 2026 13:27:58 +0000 [thread overview]
Message-ID: <sashiko-outbox-243398@kernel.org> (raw)
In-Reply-To: <20261201131537.161860-1-r.mereu.kernel@arduino.cc>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] soc: qcom: apr: uninitialized resp.payload for zero-payload
packets
--
commit 3dd22a18cdfc965891e87fd5f0f5bbf91090ba36
Author: Riccardo Mereu <r.mereu@arduino.cc>
soc: qcom: apr: accept packets without payload
This commit relaxes the packet size check in apr_do_rx_callback() and
gpr_do_rx_callback() to allow packets whose total size equals their header
size.
> diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c
> index 5157293747620..55f9b6a4bb76c 100644
> --- a/drivers/soc/qcom/apr.c
> +++ b/drivers/soc/qcom/apr.c
> @@ -218,7 +218,7 @@ static int apr_do_rx_callback(struct packet_router *apr, struct apr_rx_buf *abuf
> }
>
> if (hdr->pkt_size < APR_HDR_SIZE || hdr->pkt_size != len ||
> - hdr->pkt_size <= hdr_size) {
> + hdr->pkt_size < hdr_size) {
> dev_err(apr->dev, "APR: Wrong packet size\n");
> return -EINVAL;
> }
> @@ -289,7 +289,7 @@ static int gpr_do_rx_callback(struct packet_router *gpr, struct apr_rx_buf *abuf
> }
>
> if (hdr->pkt_size < GPR_PKT_HEADER_BYTE_SIZE || hdr->pkt_size != len ||
> - hdr->pkt_size <= hdr_size * 4) {
> + hdr->pkt_size < hdr_size * 4) {
> dev_err(gpr->dev, "GPR: Wrong packet size\n");
> return -EINVAL;
> }
[Severity: Medium]
Does allowing zero-payload packets leave resp.payload uninitialized on the
stack in both apr_do_rx_callback() and gpr_do_rx_callback()?
In both functions, resp is declared on the stack without initialization and
resp.payload is only assigned when resp.payload_size > 0:
drivers/soc/qcom/apr.c:apr_do_rx_callback() {
...
resp.hdr = *hdr;
resp.payload_size = hdr->pkt_size - hdr_size;
...
if (resp.payload_size > 0)
resp.payload = buf + hdr_size;
adrv->callback(adev, &resp);
}
When hdr->pkt_size equals the header size (such as on
ASM_DATA_EVENT_RENDERED_EOS), resp.payload_size is 0 and resp.payload holds
stack garbage. Service callbacks such as q6asm_stream_callback() and
graph_callback() unconditionally read data->payload and pass it to their
client callbacks, and other opcode handlers that do not check
data->payload_size will dereference an uninitialized pointer instead of
NULL. Zero-initializing resp (or setting resp.payload = NULL) avoids this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201131537.161860-1-r.mereu.kernel@arduino.cc?part=1
prev parent reply other threads:[~2026-12-01 13:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 13:15 [PATCH] soc: qcom: apr: accept packets without payload Riccardo Mereu
2026-12-01 13:27 ` 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-243398@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=r.mereu.kernel@arduino.cc \
--cc=sashiko-reviews@lists.linux.dev \
/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