[2/5] tty: Get driver for info once

Submitted by Pavel Emelianov on July 19, 2017, 11:20 a.m.

Details

Message ID 96c42d38-e42e-f7cb-eb04-d0918159303e@virtuozzo.com
State Accepted
Series "Merge tty files into files image"
Headers show

Commit Message

Pavel Emelianov July 19, 2017, 11:20 a.m.
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 <xemul@virtuozzo.com>
---
 criu/tty.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/tty.c b/criu/tty.c
index 6ce3eb6..222309b 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1515,6 +1515,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);
 
@@ -1540,11 +1541,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))
@@ -1589,12 +1598,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;