mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
Kernel: Get RefPtr<Device> from the DeviceManagement::get_device method
Instead of returning a raw pointer, which could be technically invalid when using it in the caller function, we return a valid RefPtr of such device. This ensures that the code in DevPtsFS is now safe from a rare race condition in which the SlavePTY device is gone but we still have a pointer to it.
This commit is contained in:
parent
5dcf03ad9a
commit
11ead5c84f
6 changed files with 24 additions and 16 deletions
|
@ -16,11 +16,16 @@ static InodeIndex pty_index_to_inode_index(unsigned pty_index)
|
|||
return pty_index + 2;
|
||||
}
|
||||
|
||||
DevPtsFSInode::DevPtsFSInode(DevPtsFS& fs, InodeIndex index, SlavePTY* pty)
|
||||
: Inode(fs, index)
|
||||
// NOTE: This constructor is used for the root inode only.
|
||||
DevPtsFSInode::DevPtsFSInode(DevPtsFS& fs)
|
||||
: Inode(fs, 1)
|
||||
{
|
||||
}
|
||||
|
||||
DevPtsFSInode::DevPtsFSInode(DevPtsFS& fs, InodeIndex index, SlavePTY& pty)
|
||||
: Inode(fs, index)
|
||||
, m_pty(pty)
|
||||
{
|
||||
if (pty)
|
||||
m_pty = *pty;
|
||||
}
|
||||
|
||||
DevPtsFSInode::~DevPtsFSInode() = default;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue