# \[PATCH v2 5/7\] tty: serial: check ops before registering console

- Subsystems: THE REST, TTY LAYER AND SERIAL DRIVERS
- Maintainers: Linus Torvalds, Greg Kroah-Hartman, Jiri Slaby
- List: linux-arm-kernel
- 1 message, 1 author
- Page: https://ratatoskr.run/linux-arm-kernel/2011/07/8053758/t

## \[PATCH v2 5/7\] tty: serial: check ops before registering console

- From: Haojian Zhuang \<hidden\>
- Date: 2011-07-28 06:41:31 
- Message: https://ratatoskr.run/linux-arm-kernel/2011/07/8053758.md

```text
Console should be only registered after port->ops assigned. If uart console
doesn't match the current uart, port->ops keeps NULL.

Signed-off-by: Haojian Zhuang <redacted>
---
 drivers/tty/serial/pxa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index dadd201..3201a95 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -683,7 +683,7 @@ serial_pxa_console_setup(struct console *co, char *options)
 	if (co->index == -1 || co->index >= serial_pxa_reg.nr)
 		co->index = 0;
 	up = serial_pxa_ports[co->index];
-	if (!up)
+	if (!up || !up->port.ops)
 		return -ENODEV;
 
 	if (options)
-- 
1.5.6.5
```
