Module: xenomai-3 Branch: stable-3.0.x Commit: 50ef005105d07916d4202bf6d09a5c87fca828f5 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=50ef005105d07916d4202bf6d09a5c87fca828f5
Author: Philippe Gerum <r...@xenomai.org> Date: Sun May 13 16:21:13 2018 +0200 drivers/serial: imx: prevent call from invalid runtime mode --- kernel/drivers/serial/rt_imx_uart.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kernel/drivers/serial/rt_imx_uart.c b/kernel/drivers/serial/rt_imx_uart.c index 61836ae..1aec219 100644 --- a/kernel/drivers/serial/rt_imx_uart.c +++ b/kernel/drivers/serial/rt_imx_uart.c @@ -963,6 +963,13 @@ static int rt_imx_uart_ioctl(struct rtdm_fd *fd, struct rtser_config config_buf; uint64_t *hist_buf = NULL; + /* + * We may call regular kernel services ahead, ask for + * re-entering secondary mode if need be. + */ + if (rtdm_in_rt_context()) + return -ENOSYS; + config = (struct rtser_config *)arg; if (rtdm_fd_is_user(fd)) { @@ -984,13 +991,6 @@ static int rt_imx_uart_ioctl(struct rtdm_fd *fd, return -EINVAL; if (config->config_mask & RTSER_SET_TIMESTAMP_HISTORY) { - /* - * Reflect the call to non-RT as we will likely - * allocate or free the buffer. - */ - if (rtdm_in_rt_context()) - return -ENOSYS; - if (config->timestamp_history & RTSER_RX_TIMESTAMP_HISTORY) hist_buf = kmalloc(IN_BUFFER_SIZE * @@ -1000,7 +1000,8 @@ static int rt_imx_uart_ioctl(struct rtdm_fd *fd, rt_imx_uart_set_config(ctx, config, &hist_buf); - kfree(hist_buf); + if (hist_buf) + kfree(hist_buf); break; } _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git