summaryrefslogtreecommitdiff
path: root/Kernel/Devices
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-06-17 19:29:49 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-17 19:52:13 +0200
commit9b14a8605a8ef4ab81141f7baff634d472912beb (patch)
tree253a96c5bcfc239d1f1ee0a672401b9d2c9a5108 /Kernel/Devices
parent017c5fc7d9379831b0bc9bfea73262e47f152cb3 (diff)
downloadserenity-9b14a8605a8ef4ab81141f7baff634d472912beb.zip
Kernel: Add a VERIFY() to make sure our DMA address is valid
This checks whether the address we're trying to use for DMA is low enough so as not to overflow the I/O register.
Diffstat (limited to 'Kernel/Devices')
-rw-r--r--Kernel/Devices/SB16.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp
index ec29fe28b0..83b3c20289 100644
--- a/Kernel/Devices/SB16.cpp
+++ b/Kernel/Devices/SB16.cpp
@@ -200,6 +200,9 @@ void SB16::dma_start(uint32_t length)
// Write the buffer
IO::out8(0x8b, addr >> 16);
+ auto page_number = addr >> 16;
+ VERIFY(page_number <= NumericLimits<u8>::max());
+ IO::out8(0x8b, page_number);
// Enable the DMA channel
IO::out8(0xd4, (channel % 4));