Skip to content

Commit

Permalink
misc: bcm-vk: fix tty registration race
Browse files Browse the repository at this point in the history
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: 91ca10d ("misc: bcm-vk: add ttyVK support")
Cc: stable@vger.kernel.org      # 5.12
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210917115736.5816-1-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jhovold authored and gregkh committed Sep 21, 2021
1 parent 50c7ad3 commit d9d1232
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/misc/bcm-vk/bcm_vk_tty.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit d9d1232

Please sign in to comment.