Skip to content

Commit 706cc5a

Browse files
Nirbhay Sharmagregkh
authored andcommitted
staging: greybus: uart: check return values during probe
Check the return values of send_control() and send_line_coding() during device initialization in gb_uart_probe(). If these operations fail, the device will be left in an inconsistent state, so propagate the error to properly fail the probe. Both functions call gb_operation_sync() which can fail with errors such as -ENOMEM, -ENODEV, or -ETIMEDOUT. Ignoring these errors means the TTY device would be registered despite incomplete initialization. Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com> Link: https://patch.msgid.link/20251115061646.160847-2-nirbhay.lkd@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 47d3949 commit 706cc5a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/staging/greybus/uart.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,14 +879,18 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
879879
if (retval)
880880
goto exit_put_port;
881881

882-
send_control(gb_tty, gb_tty->ctrlout);
882+
retval = send_control(gb_tty, gb_tty->ctrlout);
883+
if (retval)
884+
goto exit_connection_disable;
883885

884886
/* initialize the uart to be 9600n81 */
885887
gb_tty->line_coding.rate = cpu_to_le32(9600);
886888
gb_tty->line_coding.format = GB_SERIAL_1_STOP_BITS;
887889
gb_tty->line_coding.parity = GB_SERIAL_NO_PARITY;
888890
gb_tty->line_coding.data_bits = 8;
889-
send_line_coding(gb_tty);
891+
retval = send_line_coding(gb_tty);
892+
if (retval)
893+
goto exit_connection_disable;
890894

891895
retval = gb_connection_enable(connection);
892896
if (retval)

0 commit comments

Comments
 (0)