Skip to content

Commit 65c001d

Browse files
jhovoldgregkh
authored andcommitted
ipack: ipoctal: fix tty registration race
Make sure to set the tty class-device driver data before registering the tty to avoid having a racing open() dereference a NULL pointer. Fixes: 9c1d784 ("Staging: ipack/devices/ipoctal: Get rid of ipoctal_list.") Cc: [email protected] # 3.7 Acked-by: Samuel Iglesias Gonsalvez <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a89936c commit 65c001d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/ipack/devices/ipoctal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,13 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
392392
spin_lock_init(&channel->lock);
393393
channel->pointer_read = 0;
394394
channel->pointer_write = 0;
395-
tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL);
395+
tty_dev = tty_port_register_device_attr(&channel->tty_port, tty,
396+
i, NULL, channel, NULL);
396397
if (IS_ERR(tty_dev)) {
397398
dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
398399
tty_port_destroy(&channel->tty_port);
399400
continue;
400401
}
401-
dev_set_drvdata(tty_dev, channel);
402402
}
403403

404404
/*

0 commit comments

Comments
 (0)