Commit e21de14
serial: Clear UPF_DEAD before calling tty_port_register_device_attr_serdev()
If a serdev_device_driver is already loaded for a serdev_tty_port when it
gets registered by tty_port_register_device_attr_serdev() then that
driver's probe() method will be called immediately.
The serdev_device_driver's probe() method should then be able to call
serdev_device_open() successfully, but because UPF_DEAD is still dead
serdev_device_open() will fail with -ENXIO in this scenario:
serdev_device_open()
ctrl->ops->open() /* this callback being ttyport_open() */
tty->ops->open() /* this callback being uart_open() */
tty_port_open()
port->ops->activate() /* this callback being uart_port_activate() */
Find bit UPF_DEAD is set in uport->flags and fail with errno -ENXIO.
Fix this be clearing UPF_DEAD before tty_port_register_device_attr_serdev()
note this only moves up the UPD_DEAD clearing a small bit, before:
tty_port_register_device_attr_serdev();
mutex_unlock(&tty_port.mutex);
uart_port.flags &= ~UPF_DEAD;
mutex_unlock(&port_mutex);
after:
uart_port.flags &= ~UPF_DEAD;
tty_port_register_device_attr_serdev();
mutex_unlock(&tty_port.mutex);
mutex_unlock(&port_mutex);
Reported-by: Weifeng Liu <weifeng.liu.z@gmail.com>
Closes: https://lore.kernel.org/platform-driver-x86/20240505130800.2546640-1-weifeng.liu.z@gmail.com/
Tested-by: Weifeng Liu <weifeng.liu.z@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240509141549.63704-1-hdegoede@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent a3d8728 commit e21de14
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3207 | 3207 | | |
3208 | 3208 | | |
3209 | 3209 | | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
3210 | 3213 | | |
3211 | 3214 | | |
3212 | 3215 | | |
| |||
3217 | 3220 | | |
3218 | 3221 | | |
3219 | 3222 | | |
| 3223 | + | |
3220 | 3224 | | |
3221 | 3225 | | |
3222 | 3226 | | |
| |||
3426 | 3430 | | |
3427 | 3431 | | |
3428 | 3432 | | |
3429 | | - | |
3430 | | - | |
3431 | 3433 | | |
3432 | 3434 | | |
3433 | 3435 | | |
| |||
0 commit comments