SIGN IN SIGN UP

tty: skip cdev_del() when no cdev is registered

TTY device registration can fail before a cdev is allocated.
Serial core keeps the port so setserial can still use it, and later
removal passes the NULL cdev slot to cdev_del(), causing a NULL-pointer
dereference.

Only delete the cdev when the slot is not NULL.

Fixes: a3a10ce3429e ("Avoid usb reset crashes by making tty_io cdevs truly dynamic")
Fixes: da4c279942b0 ("serial: enable serdev support")
Assisted-by: Claude:claude-fable-5
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Link: https://patch.msgid.link/20260731181844.11330-4-kmehltretter@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
K
Karl Mehltretter committed
c3b5623fd97648f2747444aa8932ae604662df93
Parent: 61a2fb2
Committed by Greg Kroah-Hartman <gregkh@linuxfoundation.org> on 8/3/2026, 2:53:09 PM