On 20. 02. 25, 22:48, Magnus Lindholm wrote:
I've applied and verified this patch on an Alphaserver ES40 with serial console. Regarding the future use of label err_free_drv, is the intention to use it to break out early if tty_alloc_driver() fails?
...
+ if (!srm_is_registered_console) + return -ENODEV; + + driver = tty_alloc_driver(MAX_SRM_CONSOLE_DEVICES, 0); + if (IS_ERR(driver)) + return PTR_ERR(driver); + + tty_port_init(&srmcons_singleton.port); + + driver->driver_name = "srm"; + driver->name = "srm"; + driver->major = 0; /* dynamic */ + driver->minor_start = 0; + driver->type = TTY_DRIVER_TYPE_SYSTEM; + driver->subtype = SYSTEM_TYPE_SYSCONS; + driver->init_termios = tty_std_termios; + tty_set_operations(driver, &srmcons_ops); + tty_port_link_device(&srmcons_singleton.port, driver, 0);
I plan on removing tty_port_link_device() as it was a temporary aid. Yay, for 13 years! (commit 2cb4ca0208722).
+ err = tty_register_driver(driver); + if (err) + goto err_free_drv;
Instead, the idea is to properly tty_port_register_device() after tty_register_driver() instead. And that can fail. So is fail path reuses err_free_drv (and adds tty_unregister_driver() on top).
+ + srmcons_driver = driver; + + return 0; +err_free_drv: + tty_driver_kref_put(driver); + tty_port_destroy(&srmcons_singleton.port); + + return err;
thanks, -- js suse labs