From 0155e910dcb7d6ec16039f7fdeff2e4c722c7e35 Mon Sep 17 00:00:00 2001 From: ligd Date: Mon, 7 Feb 2022 10:45:18 +0800 Subject: [PATCH] serial: fix cu crash caused by ioctl is NULL Signed-off-by: ligd --- drivers/serial/serial.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index ccf52647f97..a6bdbf5b248 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -1280,7 +1280,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) /* Let low-level driver handle the call first */ - int ret = dev->ops->ioctl(filep, cmd, arg); + int ret = dev->ops->ioctl ? dev->ops->ioctl(filep, cmd, arg) : -ENOTTY; /* The device ioctl() handler returns -ENOTTY when it doesn't know * how to handle the command. Check if we can handle it here. @@ -1458,6 +1458,8 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) termiosp->c_iflag = dev->tc_iflag; termiosp->c_oflag = dev->tc_oflag; termiosp->c_lflag = dev->tc_lflag; + + ret = 0; } break; @@ -1476,6 +1478,8 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) dev->tc_iflag = termiosp->c_iflag; dev->tc_oflag = termiosp->c_oflag; dev->tc_lflag = termiosp->c_lflag; + + ret = 0; } break; }