Skip to content

Commit 82a0a3e

Browse files
Dan Carpenterbroonie
authored andcommitted
ASoC: renesas: rz-ssi: Add a check for negative sample_space
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: [email protected] Fixes: 03e786b ("ASoC: sh: Add RZ/G2L SSIF-2 driver") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 9c3d68c commit 82a0a3e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sound/soc/renesas/rz-ssi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ static int rz_ssi_pio_send(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
521521
sample_space = strm->fifo_sample_size;
522522
ssifsr = rz_ssi_reg_readl(ssi, SSIFSR);
523523
sample_space -= (ssifsr >> SSIFSR_TDC_SHIFT) & SSIFSR_TDC_MASK;
524+
if (sample_space < 0)
525+
return -EINVAL;
524526

525527
/* Only add full frames at a time */
526528
while (frames_left && (sample_space >= runtime->channels)) {

0 commit comments

Comments
 (0)