tty: retain reference to foreground tty and input devices
This commit is contained in:
@@ -97,9 +97,10 @@ void tty_set_foreground(struct device *tty)
|
|||||||
bool console_init = false;
|
bool console_init = false;
|
||||||
if (foreground) {
|
if (foreground) {
|
||||||
console_init = true;
|
console_init = true;
|
||||||
|
device_deref(foreground);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreground = tty;
|
foreground = device_ref(tty);
|
||||||
|
|
||||||
if (!console_init) {
|
if (!console_init) {
|
||||||
console_register(&tty_console);
|
console_register(&tty_console);
|
||||||
@@ -123,11 +124,11 @@ kern_status_t tty_connect_foreground_input_device(struct device *input)
|
|||||||
device_lock(prev);
|
device_lock(prev);
|
||||||
input_device_remove_hook(prev, &foreground_input_hook);
|
input_device_remove_hook(prev, &foreground_input_hook);
|
||||||
device_unlock(prev);
|
device_unlock(prev);
|
||||||
|
device_deref(prev);
|
||||||
object_deref(&prev->dev_base);
|
object_deref(&prev->dev_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ref(&input->dev_base);
|
foreground_input = device_ref(input);
|
||||||
foreground_input = input;
|
|
||||||
device_lock(input);
|
device_lock(input);
|
||||||
input_device_add_hook(input, &foreground_input_hook);
|
input_device_add_hook(input, &foreground_input_hook);
|
||||||
device_unlock(input);
|
device_unlock(input);
|
||||||
|
|||||||
Reference in New Issue
Block a user