misc: bcm-vk: fix tty registration race
Subsystems (3)
PATCH 1/1 misc: bcm-vk: 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 91ca10d6fa07 ("misc: bcm-vk: add ttyVK support")
Cc [email protected] # 5.12
Signed-off-by Johan Hovold <[email protected]>
--- drivers/misc/bcm-vk/bcm_vk_tty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/misc/bcm-vk/bcm_vk_tty.c +3 -3
@@ -267,13 +267,13 @@ int bcm_vk_tty_init(struct bcm_vk *vk, char *name)struct device *tty_dev;tty_port_init (&vk->tty[i].port); - tty_dev =tty_port_register_device (&vk->tty[i].port, tty_drv, - i, dev); + tty_dev =tty_port_register_device_attr (&vk->tty[i].port, + tty_drv, i, dev, vk, +NULL );if (IS_ERR (tty_dev)) { err =PTR_ERR (tty_dev); goto unwind; } -dev_set_drvdata (tty_dev, vk); vk->tty[i].is_opened = false; }
Signature · 1 line
2.32.0