]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: greybus: uart: check return values during probe
authorNirbhay Sharma <nirbhay.lkd@gmail.com>
Sat, 15 Nov 2025 06:16:47 +0000 (11:46 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Nov 2025 16:53:49 +0000 (17:53 +0100)
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>
drivers/staging/greybus/uart.c

index 10df5c37c83ede2d8641439e1923ebdc1f48c20d..5cece0a6606fda358742c465a918e6828d6bf585 100644 (file)
@@ -879,14 +879,18 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
        if (retval)
                goto exit_put_port;
 
-       send_control(gb_tty, gb_tty->ctrlout);
+       retval = send_control(gb_tty, gb_tty->ctrlout);
+       if (retval)
+               goto exit_connection_disable;
 
        /* initialize the uart to be 9600n81 */
        gb_tty->line_coding.rate = cpu_to_le32(9600);
        gb_tty->line_coding.format = GB_SERIAL_1_STOP_BITS;
        gb_tty->line_coding.parity = GB_SERIAL_NO_PARITY;
        gb_tty->line_coding.data_bits = 8;
-       send_line_coding(gb_tty);
+       retval = send_line_coding(gb_tty);
+       if (retval)
+               goto exit_connection_disable;
 
        retval = gb_connection_enable(connection);
        if (retval)