Bläddra i källkod

Kernel: Fix reading expansion ROM SysFS node

Previously, reads would only be successful for offset 0. For this
reason, the maximum size that could be correctly read from the PCI
expansion ROM SysFS node was limited to the block size, and
subsequent blocks would fail. This commit fixes the computation of
the number of bytes to read.
Robin Voetter 2 år sedan
förälder
incheckning
a433cbefbe
1 ändrade filer med 3 tillägg och 6 borttagningar
  1. 3 6
      Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceExpansionROM.cpp

+ 3 - 6
Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceExpansionROM.cpp

@@ -39,12 +39,9 @@ ErrorOr<size_t> PCIDeviceExpansionROMSysFSComponent::read_bytes(off_t offset, si
     if (unsigned_offset >= m_option_rom_size)
         return 0;
 
-    auto blob = TRY(try_to_generate_buffer(unsigned_offset, count));
-    if (static_cast<size_t>(offset) >= blob->size())
-        return 0;
-
-    ssize_t nread = min(static_cast<off_t>(blob->size() - offset), static_cast<off_t>(count));
-    TRY(buffer.write(blob->data() + offset, nread));
+    ssize_t nread = min(static_cast<off_t>(m_option_rom_size - offset), static_cast<off_t>(count));
+    auto blob = TRY(try_to_generate_buffer(unsigned_offset, nread));
+    TRY(buffer.write(blob->bytes()));
     return nread;
 }