1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:57:46 +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

@ -16,7 +16,7 @@ namespace Kernel {
class MemoryDevice final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
MemoryDevice();
static NonnullRefPtr<MemoryDevice> must_create();
~MemoryDevice();
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
@ -26,6 +26,7 @@ public:
virtual String device_name() const override { return "mem"; };
private:
MemoryDevice();
virtual const char* class_name() const override { return "MemoryDevice"; }
virtual bool can_read(const FileDescription&, size_t) const override { return true; }
virtual bool can_write(const FileDescription&, size_t) const override { return false; }