mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
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.
This commit is contained in:
parent
c90136d48d
commit
a433cbefbe
Notes:
sideshowbarker
2024-07-17 10:31:19 +09:00
Author: https://github.com/Snektron 🔰 Commit: https://github.com/SerenityOS/serenity/commit/a433cbefbe Pull-request: https://github.com/SerenityOS/serenity/pull/19451 Reviewed-by: https://github.com/gmta ✅
1 changed files with 3 additions and 6 deletions
|
@ -39,12 +39,9 @@ ErrorOr<size_t> PCIDeviceExpansionROMSysFSComponent::read_bytes(off_t offset, si
|
||||||
if (unsigned_offset >= m_option_rom_size)
|
if (unsigned_offset >= m_option_rom_size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
auto blob = TRY(try_to_generate_buffer(unsigned_offset, count));
|
ssize_t nread = min(static_cast<off_t>(m_option_rom_size - offset), static_cast<off_t>(count));
|
||||||
if (static_cast<size_t>(offset) >= blob->size())
|
auto blob = TRY(try_to_generate_buffer(unsigned_offset, nread));
|
||||||
return 0;
|
TRY(buffer.write(blob->bytes()));
|
||||||
|
|
||||||
ssize_t nread = min(static_cast<off_t>(blob->size() - offset), static_cast<off_t>(count));
|
|
||||||
TRY(buffer.write(blob->data() + offset, nread));
|
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue