mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
Kernel: Handle allocation failure in ProcFS and friends
There were many places in which allocation failure was noticed but ignored.
This commit is contained in:
parent
134dbe2607
commit
748938ea59
Notes:
sideshowbarker
2024-07-18 05:42:35 +09:00
Author: https://github.com/sin-ack
Commit: 748938ea59
Pull-request: https://github.com/SerenityOS/serenity/pull/9410
Reviewed-by: https://github.com/awesomekling
8 changed files with 196 additions and 92 deletions
|
@ -926,17 +926,27 @@ KResult ProcFSRootDirectory::traverse_as_directory(unsigned fsid, Function<bool(
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
RefPtr<ProcFSExposedComponent> ProcFSRootDirectory::lookup(StringView name)
|
||||
KResultOr<NonnullRefPtr<ProcFSExposedComponent>> ProcFSRootDirectory::lookup(StringView name)
|
||||
{
|
||||
if (auto candidate = ProcFSExposedDirectory::lookup(name); !candidate.is_null())
|
||||
return candidate;
|
||||
auto maybe_candidate = ProcFSExposedDirectory::lookup(name);
|
||||
if (maybe_candidate.is_error()) {
|
||||
if (maybe_candidate.error() != ENOENT) {
|
||||
return maybe_candidate.error();
|
||||
}
|
||||
} else {
|
||||
return maybe_candidate.release_value();
|
||||
}
|
||||
|
||||
String process_directory_name = name;
|
||||
auto pid = process_directory_name.to_uint<unsigned>();
|
||||
if (!pid.has_value())
|
||||
return {};
|
||||
return ESRCH;
|
||||
auto actual_pid = pid.value();
|
||||
return Process::from_pid(actual_pid);
|
||||
|
||||
auto maybe_process = Process::from_pid(actual_pid);
|
||||
if (maybe_process)
|
||||
return maybe_process.release_nonnull();
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT ProcFSRootDirectory::ProcFSRootDirectory()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue