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@xxxxxxxxxxxxxxxxxxxxx>
---
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