diff options
| author | Dan Carpenter <dan.carpenter@linaro.org> | 2025-01-08 12:28:46 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-17 11:36:30 +0100 |
| commit | 77d6c38c4a4c22ffeea8ddbd0396c362694ce4d3 (patch) | |
| tree | 8ea5aad293e25dcb1c283e6b21b9654621834702 /sound | |
| parent | 4ffd4775167d72f619cb0e988b688dbb54d773df (diff) | |
| download | linux-77d6c38c4a4c22ffeea8ddbd0396c362694ce4d3.tar.gz linux-77d6c38c4a4c22ffeea8ddbd0396c362694ce4d3.tar.bz2 linux-77d6c38c4a4c22ffeea8ddbd0396c362694ce4d3.zip | |
ASoC: renesas: rz-ssi: Add a check for negative sample_space
commit 82a0a3e6f8c02b3236b55e784a083fa4ee07c321 upstream.
My static checker rule complains about this code. The concern is that
if "sample_space" is negative then the "sample_space >= runtime->channels"
condition will not work as intended because it will be type promoted to a
high unsigned int value.
strm->fifo_sample_size is SSI_FIFO_DEPTH (32). The SSIFSR_TDC_MASK is
0x3f. Without any further context it does seem like a reasonable warning
and it can't hurt to add a check for negatives.
Cc: stable@vger.kernel.org
Fixes: 03e786bd4341 ("ASoC: sh: Add RZ/G2L SSIF-2 driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/e07c3dc5-d885-4b04-a742-71f42243f4fd@stanley.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound')
| -rw-r--r-- | sound/soc/renesas/rz-ssi.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sound/soc/renesas/rz-ssi.c b/sound/soc/renesas/rz-ssi.c index 178c915331e9..b7874dd42b2a 100644 --- a/sound/soc/renesas/rz-ssi.c +++ b/sound/soc/renesas/rz-ssi.c @@ -526,6 +526,8 @@ static int rz_ssi_pio_send(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) sample_space = strm->fifo_sample_size; ssifsr = rz_ssi_reg_readl(ssi, SSIFSR); sample_space -= (ssifsr >> SSIFSR_TDC_SHIFT) & SSIFSR_TDC_MASK; + if (sample_space < 0) + return -EINVAL; /* Only add full frames at a time */ while (frames_left && (sample_space >= runtime->channels)) { |
