Re: [PATCH v11 10/10] tty: serial: Add Nuvoton ma35d1 serial driver support

From: Jiri Slaby
Date: Tue May 30 2023 - 01:35:59 EST


Hi,

On 30. 05. 23, 3:09, Jacky Huang wrote:
+
+    if (options)
+        uart_parse_options(options, &baud, &parity, &bits, &flow);
+
+    return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct console ma35d1serial_console = {
+    .name    = "ttyNVT",
+    .write   = ma35d1serial_console_write,
+    .device  = uart_console_device,
+    .setup   = ma35d1serial_console_setup,
+    .flags   = CON_PRINTBUFFER | CON_ENABLED,
+    .index   = -1,
+    .data    = &ma35d1serial_reg,

I don't see console->data used anywhere in the driver?


I will remove it.


I removed the " .data    = &ma35d1serial_reg", but kernel crashed in 'drivers/tty/serial/serial_core.c'.

The variable 'p' of  uart_console_device() refer to a NULL, because co->data is NULL.
As a result, kernel crashed at 'p->tty_driver'.

struct tty_driver *uart_console_device(struct console *co, int *index)
{
    struct uart_driver *p = co->data;
    *index = co->index;
    return p->tty_driver;
}

We seem to be unable to remove it.
If there are no other considerations, I will keep it in the next version.

Ah, yeah. Sorry, my bad.

--
js
suse labs