From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Fred Treven <ftreven@opensource.cirrus.com>
Cc: Simon Trimmer <simont@opensource.cirrus.com>,
Richard Fitzgerald <rf@opensource.cirrus.com>,
<patches@opensource.cirrus.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/7] firmware: cs_dsp: Check for valid num_regs in cs_dsp_wseq_multi_write()
Date: Tue, 4 Feb 2025 10:06:04 +0000 [thread overview]
Message-ID: <Z6HmjEBIOfQYomXc@opensource.cirrus.com> (raw)
In-Reply-To: <20250131195639.1784933-3-ftreven@opensource.cirrus.com>
On Fri, Jan 31, 2025 at 01:56:33PM -0600, Fred Treven wrote:
> If a value of 0 or below is passed into cs_dsp_wseq_multi_write()
> the function will never enter its for loop.
>
> Verify that num_regs passed into the function is valid
> and throw a user-visible error if not.
>
> Signed-off-by: Fred Treven <ftreven@opensource.cirrus.com>
> ---
> drivers/firmware/cirrus/cs_dsp.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
> index 56315b0b5583..aacf6960d1ea 100644
> --- a/drivers/firmware/cirrus/cs_dsp.c
> +++ b/drivers/firmware/cirrus/cs_dsp.c
> @@ -3743,6 +3743,11 @@ int cs_dsp_wseq_multi_write(struct cs_dsp *dsp, struct cs_dsp_wseq *wseq,
> {
> int i, ret;
>
> + if (num_regs <= 0) {
> + cs_dsp_err(dsp, "Invalid number of regs: %d\n", num_regs);
> + return -EINVAL;
> + }
> +
This feels a little defensive, do we really need to check for
this? Normally num_regs is going to come from an ARRAY_SIZE or
something.
Thanks,
Charles
next prev parent reply other threads:[~2025-02-04 10:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250131195639.1784933-1-ftreven@opensource.cirrus.com>
2025-01-31 19:56 ` [PATCH 1/7] firmware: cs_dsp: Fix error checking in wseq_write() Fred Treven
2025-02-02 17:34 ` Markus Elfring
2025-02-04 10:03 ` Charles Keepax
2025-01-31 19:56 ` [PATCH 2/7] firmware: cs_dsp: Check for valid num_regs in cs_dsp_wseq_multi_write() Fred Treven
2025-02-04 10:06 ` Charles Keepax [this message]
2025-02-04 21:51 ` Fredrik Treven
2025-01-31 19:56 ` [PATCH 3/7] firmware: cs_dsp: Add ability to load multiple coefficient files Fred Treven
2025-02-04 10:10 ` Charles Keepax
2025-02-04 22:05 ` Fredrik Treven
2025-01-31 19:56 ` [PATCH 4/7] dt-bindings: mfd: cirrus,cs40l26: Support for CS40L26 Fred Treven
2025-02-02 14:04 ` Krzysztof Kozlowski
2025-02-04 22:18 ` Fredrik Treven
2025-02-05 7:29 ` Krzysztof Kozlowski
2025-01-31 19:56 ` [PATCH 5/7] mfd: cs40l26: Add support for CS40L26 core driver Fred Treven
2025-01-31 19:56 ` [PATCH 6/7] ASoC: cs40l26: Support I2S streaming to CS40L26 Fred Treven
2025-02-03 12:23 ` Mark Brown
2025-02-04 21:54 ` Fredrik Treven
2025-01-31 19:56 ` [PATCH 7/7] Input: cs40l26 - Add support for CS40L26 haptic driver Fred Treven
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=Z6HmjEBIOfQYomXc@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=ftreven@opensource.cirrus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rf@opensource.cirrus.com \
--cc=simont@opensource.cirrus.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.