tty: retain reference to foreground tty and input devices

This commit is contained in:
2023-06-14 21:45:05 +01:00
parent 1c20efc36e
commit 31a4e00fdc

View File

@@ -97,9 +97,10 @@ void tty_set_foreground(struct device *tty)
bool console_init = false;
if (foreground) {
console_init = true;
device_deref(foreground);
}
foreground = tty;
foreground = device_ref(tty);
if (!console_init) {
console_register(&tty_console);
@@ -123,11 +124,11 @@ kern_status_t tty_connect_foreground_input_device(struct device *input)
device_lock(prev);
input_device_remove_hook(prev, &foreground_input_hook);
device_unlock(prev);
device_deref(prev);
object_deref(&prev->dev_base);
}
object_ref(&input->dev_base);
foreground_input = input;
foreground_input = device_ref(input);
device_lock(input);
input_device_add_hook(input, &foreground_input_hook);
device_unlock(input);