From c93edee2cb69bcd750560f2c8640d30632be8af6 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 19 Jul 2017 14:20:03 +0300 Subject: [PATCH] tty: Get driver for info once Since we need tty driver for info, we may lookup the guy when collecting info, not when attaching it to a file. Signed-off-by: Pavel Emelyanov Signed-off-by: Andrei Vagin --- criu/tty.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/criu/tty.c b/criu/tty.c index 49d2a275c..cd49f194f 100644 --- a/criu/tty.c +++ b/criu/tty.c @@ -1504,6 +1504,7 @@ static int collect_one_tty_info_entry(void *obj, ProtobufCMessage *msg, struct c { struct tty_info *info, *n; TtyInfoEntry *tie; + struct tty_driver *driver; tie = pb_msg(msg, TtyInfoEntry); @@ -1529,11 +1530,19 @@ static int collect_one_tty_info_entry(void *obj, ProtobufCMessage *msg, struct c return -1; } + driver = get_tty_driver(tie->rdev, tie->dev); + if (driver == NULL) { + pr_err("Unable to find a tty driver (rdev %#x dev %#x)\n", + tie->rdev, tie->dev); + return -1; + } + list_for_each_entry_safe(info, n, &collected_ttys, list) { if (info->tfe->tty_info_id != tie->id) continue; info->tie = tie; + info->driver = driver; list_move_tail(&info->list, &all_ttys); if (tty_info_setup(info)) @@ -1578,12 +1587,6 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i) static int tty_info_setup(struct tty_info *info) { INIT_LIST_HEAD(&info->sibling); - info->driver = get_tty_driver(info->tie->rdev, info->tie->dev); - if (info->driver == NULL) { - pr_err("Unable to find a tty driver (rdev %#x dev %#x)\n", - info->tie->rdev, info->tie->dev); - return -1; - } info->create = tty_is_master(info); info->inherit = false; info->ctl_tty = NULL;