1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +00:00

Kernel: Don't use naked new statements in init process

Instead, try to create the device objects in separate static methods,
and if we fail for some odd reason to allocate memory for such devices,
just panic with that reason.
This commit is contained in:
Liav A 2021-06-18 11:37:26 +03:00 committed by Andreas Kling
parent fba3c77a04
commit 29f9a38f76
11 changed files with 74 additions and 18 deletions

View file

@ -158,10 +158,10 @@ extern "C" UNMAP_AFTER_INIT [[noreturn]] void init()
NullDevice::initialize();
if (!get_serial_debug())
new SerialDevice(IOAddress(SERIAL_COM1_ADDR), 64);
new SerialDevice(IOAddress(SERIAL_COM2_ADDR), 65);
new SerialDevice(IOAddress(SERIAL_COM3_ADDR), 66);
new SerialDevice(IOAddress(SERIAL_COM4_ADDR), 67);
(void)SerialDevice::must_create(0).leak_ref();
(void)SerialDevice::must_create(1).leak_ref();
(void)SerialDevice::must_create(2).leak_ref();
(void)SerialDevice::must_create(3).leak_ref();
VMWareBackdoor::the(); // don't wait until first mouse packet
HIDManagement::initialize();
@ -243,10 +243,10 @@ void init_stage2(void*)
NetworkingManagement::the().initialize();
Syscall::initialize();
new MemoryDevice;
new ZeroDevice;
new FullDevice;
new RandomDevice;
(void)MemoryDevice::must_create().leak_ref();
(void)ZeroDevice::must_create().leak_ref();
(void)FullDevice::must_create().leak_ref();
(void)RandomDevice::must_create().leak_ref();
PTYMultiplexer::initialize();
SB16::detect();