[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] hw/dma: prevent overflow in soc_dma_set_request
|
From: |
Anastasia Belova |
|
Subject: |
[PATCH] hw/dma: prevent overflow in soc_dma_set_request |
|
Date: |
Tue, 9 Apr 2024 14:53:01 +0300 |
ch->num can reach values up to 31. Add casting to
a larger type before performing left shift to
prevent integer overflow.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: afbb5194d4 ("Handle on-chip DMA controllers in one place, convert OMAP
DMA to use it.")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
hw/dma/soc_dma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/dma/soc_dma.c b/hw/dma/soc_dma.c
index 3a430057f5..d5c52b804f 100644
--- a/hw/dma/soc_dma.c
+++ b/hw/dma/soc_dma.c
@@ -209,9 +209,9 @@ void soc_dma_set_request(struct soc_dma_ch_s *ch, int level)
dma->enabled_count += level - ch->enable;
if (level)
- dma->ch_enable_mask |= 1 << ch->num;
+ dma->ch_enable_mask |= (uint64_t)1 << ch->num;
else
- dma->ch_enable_mask &= ~(1 << ch->num);
+ dma->ch_enable_mask &= ~((uint64_t)1 << ch->num);
if (level != ch->enable) {
soc_dma_ch_freq_update(dma);
--
2.30.2
- [PATCH] hw/dma: prevent overflow in soc_dma_set_request,
Anastasia Belova <=