mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
BXVGADevice+MBVGADevice: Correctly check page-aligned mmaps
In ab14b0ac64
, mmap was changed so that
the size of the region is aligned before it was passed to the device
driver. The previous logic would assert when the framebuffer size was
not a multiple of the page size. I've also taken the liberty of
returning an error on mmap failure rather than asserting.
This commit is contained in:
parent
f2decb6665
commit
985ce3b701
2 changed files with 10 additions and 4 deletions
|
@ -56,8 +56,11 @@ KResultOr<Region*> MBVGADevice::mmap(Process& process, FileDescription&, const R
|
|||
REQUIRE_PROMISE(video);
|
||||
if (!shared)
|
||||
return ENODEV;
|
||||
ASSERT(offset == 0);
|
||||
ASSERT(range.size() == framebuffer_size_in_bytes());
|
||||
if (offset != 0)
|
||||
return ENXIO;
|
||||
if (range.size() != PAGE_ROUND_UP(framebuffer_size_in_bytes()))
|
||||
return EOVERFLOW;
|
||||
|
||||
auto vmobject = AnonymousVMObject::create_for_physical_range(m_framebuffer_address, framebuffer_size_in_bytes());
|
||||
if (!vmobject)
|
||||
return ENOMEM;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue