mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +00:00
Kernel: Dont crash if power states gets set to an invalid value
This commit is contained in:
parent
b4113536ef
commit
ab298ca106
1 changed files with 1 additions and 5 deletions
|
@ -57,11 +57,7 @@ ErrorOr<size_t> SysFSPowerStateSwitchNode::write_bytes(off_t offset, size_t coun
|
||||||
return Error::from_errno(EINVAL);
|
return Error::from_errno(EINVAL);
|
||||||
char buf[1];
|
char buf[1];
|
||||||
TRY(data.read(buf, 1));
|
TRY(data.read(buf, 1));
|
||||||
if (buf[0] == '0')
|
|
||||||
return Error::from_errno(EINVAL);
|
|
||||||
switch (buf[0]) {
|
switch (buf[0]) {
|
||||||
case '0':
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
case '1':
|
case '1':
|
||||||
reboot();
|
reboot();
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
@ -69,7 +65,7 @@ ErrorOr<size_t> SysFSPowerStateSwitchNode::write_bytes(off_t offset, size_t coun
|
||||||
poweroff();
|
poweroff();
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
return Error::from_errno(EINVAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue