[PATCH] serial: imx: Avoid NULL pointer dereference in bind/unbind uart device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Did bind/unbind uart5 device on i.MX6SX platform like below command, there
have NULL pointer dereference cause kernel oops.
	echo  21f4000.serial > /sys/bus/platform/drivers/imx-uart/bind
	echo  21f4000.serial > /sys/bus/platform/drivers/imx-uart/unbind

The driver does not define .release_port/.request_port for uart_ops, and
uart_remove_one_port() doesn't check if this op is NULL before calling it,
so add these interfaces to support bind/unbind operation.

Signed-off-by: Fugang Duan <fugang.duan@xxxxxxx>
---
 drivers/tty/serial/imx.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 231e7d5..bed1831 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1504,6 +1504,16 @@ static const char *imx_type(struct uart_port *port)
 	return sport->port.type == PORT_IMX ? "IMX" : NULL;
 }
 
+static void imx_release_port(struct uart_port *port)
+{
+	/* nothing to do */
+}
+
+static int imx_request_port(struct uart_port *port)
+{
+	return 0;
+}
+
 /*
  * Configure/autoconfigure the port.
  */
@@ -1651,6 +1661,8 @@ static struct uart_ops imx_pops = {
 	.flush_buffer	= imx_flush_buffer,
 	.set_termios	= imx_set_termios,
 	.type		= imx_type,
+	.release_port   = imx_release_port,
+	.request_port   = imx_request_port,
 	.config_port	= imx_config_port,
 	.verify_port	= imx_verify_port,
 #if defined(CONFIG_CONSOLE_POLL)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux