Skip to content

Commit 28f7aa0

Browse files
SurajSonawane2415broonie
authored andcommitted
ASoC: bcm63xx-pcm-whistler: fix uninit-value in i2s_dma_isr
Fix an issue detected by the Smatch tool: sound/soc/bcm/bcm63xx-pcm-whistler.c:264 i2s_dma_isr() error: uninitialized symbol 'val_1'. sound/soc/bcm/bcm63xx-pcm-whistler.c:264 i2s_dma_isr() error: uninitialized symbol 'val_2'. These errors were triggered because the variables 'val_1' and 'val_2' could remain uninitialized if 'offlevel' is zero, meaning the loop that assigns values to them does not execute. In this case, 'dma_addr_next' would use uninitialized data, potentially leading to undefined behavior. To resolve this, a conditional update for 'dma_addr_next' is added, ensuring it is assigned only when 'val_1' and 'val_2' are read. A new boolean variable 'val_read' flags when the values have been retrieved, setting 'dma_addr_next' only if valid data is available. This solution prevents the use of uninitialized data, maintaining defined behavior for 'dma_addr_next' in all cases, and aligns with expected usage of I2S RX descriptor data. Signed-off-by: Suraj Sonawane <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1157733 commit 28f7aa0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sound/soc/bcm/bcm63xx-pcm-whistler.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,16 @@ static irqreturn_t i2s_dma_isr(int irq, void *bcm_i2s_priv)
256256

257257
offlevel = (int_status & I2S_RX_DESC_OFF_LEVEL_MASK) >>
258258
I2S_RX_DESC_OFF_LEVEL_SHIFT;
259+
bool val_read = false;
259260
while (offlevel) {
260261
regmap_read(regmap_i2s, I2S_RX_DESC_OFF_ADDR, &val_1);
261262
regmap_read(regmap_i2s, I2S_RX_DESC_OFF_LEN, &val_2);
263+
val_read = true;
262264
offlevel--;
263265
}
264-
prtd->dma_addr_next = val_1 + val_2;
266+
if (val_read)
267+
prtd->dma_addr_next = val_1 + val_2;
268+
265269
ifflevel = (int_status & I2S_RX_DESC_IFF_LEVEL_MASK) >>
266270
I2S_RX_DESC_IFF_LEVEL_SHIFT;
267271

0 commit comments

Comments
 (0)