Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 9c1d784afc6f ("Staging: ipack/devices/ipoctal: Get rid of ipoctal_list.")
Cc: stable@vger.kernel.org # 3.7
Acked-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210917114622.5412-3-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
65c001df a89936cc

+2 -2
+2 -2
drivers/ipack/devices/ipoctal.c
··· 392 392 spin_lock_init(&channel->lock); 393 393 channel->pointer_read = 0; 394 394 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); 396 397 if (IS_ERR(tty_dev)) { 397 398 dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n"); 398 399 tty_port_destroy(&channel->tty_port); 399 400 continue; 400 401 } 401 - dev_set_drvdata(tty_dev, channel); 402 402 } 403 403 404 404 /*