base-hw scheduler: sanitize access to invalid head

Issue #4755
This commit is contained in:
Martin Stein 2023-02-01 14:51:54 +01:00 committed by Christian Helmuth
parent c8cf33a251
commit 5bdc88bf57
3 changed files with 7 additions and 4 deletions

View File

@ -171,7 +171,7 @@ class Kernel::Cpu : public Genode::Cpu, private Irq::Pool, private Timeout
/**
* Returns the currently active job
*/
Job & scheduled_job() const {
Job & scheduled_job() {
return *static_cast<Job *>(&_scheduler.head())->helping_destination(); }
unsigned id() const { return _id; }

View File

@ -313,9 +313,12 @@ void Cpu_scheduler::quota(Share &s, unsigned const q)
}
Cpu_share &Cpu_scheduler::head() const
Cpu_share &Cpu_scheduler::head()
{
assert(_head);
if (!_head) {
Genode::error("attempt to access invalid scheduler head");
update(_last_time);
}
return *_head;
}

View File

@ -233,7 +233,7 @@ class Kernel::Cpu_scheduler
* Accessors
*/
Share &head() const;
Share &head();
unsigned head_quota() const {
return Genode::min(_head_quota, _residual); }
unsigned quota() const { return _quota; }