From f7e38ccfe4df35be7d49b71b8e445946381c22c3 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 13 Oct 2023 16:32:32 +0300 Subject: [PATCH] Kernel: Don't crash if header type != 0 in bar region creation Also remove spammy debug printing --- kernel/kernel/PCI.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/kernel/PCI.cpp b/kernel/kernel/PCI.cpp index 68b73f1fb5..3100ca0962 100644 --- a/kernel/kernel/PCI.cpp +++ b/kernel/kernel/PCI.cpp @@ -190,7 +190,11 @@ namespace Kernel::PCI BAN::ErrorOr> BarRegion::create(PCI::Device& device, uint8_t bar_num) { - ASSERT(device.header_type() == 0x00); + if (device.header_type() != 0x00) + { + dprintln("BAR regions for non general devices are not supported"); + return BAN::Error::from_errno(ENOTSUP); + } // disable io/mem space while reading bar uint16_t command = device.read_word(PCI_REG_COMMAND); @@ -390,11 +394,9 @@ namespace Kernel::PCI { case 0x05: m_offset_msi = capability_offset; - dprintln("{}:{}.{} has MSI", m_bus, m_dev, m_func); break; case 0x11: m_offset_msi_x = capability_offset; - dprintln("{}:{}.{} has MSI-X", m_bus, m_dev, m_func); break; default: break;