linux-stable/drivers/tty
Dan Carpenter cef09673c3 serial: core: fix -EPROBE_DEFER handling in init
The -EPROBE_DEFER error path in serial_base_device_init() is a bit
awkward.  Before the call to device_initialize(dev) then we need to
manually release all the device resources.  And after the call then we
need to call put_device() to release the resources.  Doing either one
wrong will result in a leak or a use after free.

So let's wait to return -EPROBE_DEFER until after the call to
device_initialize(dev) so that way callers do not have to handle
-EPROBE_DEFER as a special case.  Now callers can just use put_device()
for clean up.

The second issue with the -EPROBE_DEFER path is that deferring is not
supposed to be a fatal error, but instead it's normal part of the
init process and the kernel recovers from it automatically.  That means
we should not print an error message but just a debug message on this
path.

Fixes: 539914240a ("serial: core: Fix probing serial_base_bus devices")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Message-ID: <18318adb-ab2c-4dcc-9f96-498a13d16b80@moroto.mountain>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-15 12:20:51 +02:00
..
hvc xen: branch for v6.3-rc4 2023-03-24 09:44:43 -07:00
ipwireless
serdev serdev: Add method to assert break signal over tty UART port 2023-04-23 21:51:25 -07:00
serial serial: core: fix -EPROBE_DEFER handling in init 2023-06-15 12:20:51 +02:00
vt vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF 2023-05-13 20:01:13 +09:00
amiserial.c tty: Convert hw_stopped in tty_struct to bool 2023-03-17 15:01:09 +01:00
ehv_bytechan.c
goldfish.c
Kconfig Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
Makefile
mips_ejtag_fdc.c
moxa.c tty: moxa: Rename dtr/rts parameters/variables to active 2023-01-19 16:04:35 +01:00
mxser.c tty: Convert hw_stopped in tty_struct to bool 2023-03-17 15:01:09 +01:00
n_gsm.c n_gsm: Use array_index_nospec() with index that comes from userspace 2023-04-20 14:11:33 +02:00
n_hdlc.c
n_null.c
n_tty.c n_tty: Reindent if condition 2023-03-17 15:01:09 +01:00
nozomi.c
pty.c tty: make tty_class a static const structure 2023-04-03 21:43:07 +02:00
rpmsg_tty.c
synclink_gt.c tty: synclink_gt: don't allocate and pass dummy flags 2023-04-20 13:32:53 +02:00
sysrq.c treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
tty.h tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH 2023-03-29 10:55:53 +02:00
tty_audit.c
tty_baudrate.c
tty_buffer.c tty: Convert tty_buffer flags to bool 2022-11-09 13:02:16 +01:00
tty_io.c Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
tty_ioctl.c tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH 2023-03-29 10:55:53 +02:00
tty_jobctrl.c
tty_ldisc.c tty: tty_ldisc: Remove the ret variable 2023-03-09 17:11:18 +01:00
tty_ldsem.c
tty_mutex.c
tty_port.c tty: Convert ->dtr_rts() to take bool argument 2023-01-19 16:04:35 +01:00
ttynull.c
vcc.c