[rtems commit] libtests/termios04: Avoid use of freed memory
Sebastian Huber
sebh at rtems.org
Thu Nov 12 07:53:30 UTC 2015
Module: rtems
Branch: master
Commit: 459ebc8397b8cb13a67ebb4cb0b7aa941fbfbf29
Changeset: http://git.rtems.org/rtems/commit/?id=459ebc8397b8cb13a67ebb4cb0b7aa941fbfbf29
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Nov 11 14:47:50 2015 +0100
libtests/termios04: Avoid use of freed memory
---
.../libtests/termios04/termios_testdriver_intr.c | 42 ++++++++++++++++++----
1 file changed, 35 insertions(+), 7 deletions(-)
diff --git a/testsuites/libtests/termios04/termios_testdriver_intr.c b/testsuites/libtests/termios04/termios_testdriver_intr.c
index 94ebe28..53764fb 100644
--- a/testsuites/libtests/termios04/termios_testdriver_intr.c
+++ b/testsuites/libtests/termios04/termios_testdriver_intr.c
@@ -181,8 +181,6 @@ rtems_device_driver termios_test_driver_initialize(
void *arg
)
{
- rtems_status_code status;
-
rtems_termios_initialize();
/*
@@ -190,15 +188,45 @@ rtems_device_driver termios_test_driver_initialize(
*/
(void) rtems_io_register_name( TERMIOS_TEST_DRIVER_DEVICE_NAME, major, 0 );
+ return RTEMS_SUCCESSFUL;
+}
+
+static int first_open(int major, int minor, void *arg)
+{
+ rtems_status_code status;
+
status = rtems_timer_create(rtems_build_name('T', 'M', 'R', 'X'), &Rx_Timer);
- if ( status )
+ if ( status != RTEMS_SUCCESSFUL )
rtems_fatal_error_occurred(1);
status = rtems_timer_create(rtems_build_name('T', 'M', 'T', 'X'), &Tx_Timer);
- if ( status )
+ if ( status != RTEMS_SUCCESSFUL )
rtems_fatal_error_occurred(1);
- return RTEMS_SUCCESSFUL;
+ return 0;
+}
+
+static int last_close(int major, int minor, void *arg)
+{
+ rtems_status_code status;
+
+ status = rtems_timer_cancel(Rx_Timer);
+ if ( status != RTEMS_SUCCESSFUL )
+ rtems_fatal_error_occurred(1);
+
+ status = rtems_timer_cancel(Tx_Timer);
+ if ( status != RTEMS_SUCCESSFUL )
+ rtems_fatal_error_occurred(1);
+
+ status = rtems_timer_delete(Rx_Timer);
+ if ( status != RTEMS_SUCCESSFUL )
+ rtems_fatal_error_occurred(1);
+
+ status = rtems_timer_delete(Tx_Timer);
+ if ( status != RTEMS_SUCCESSFUL )
+ rtems_fatal_error_occurred(1);
+
+ return 0;
}
rtems_device_driver termios_test_driver_open(
@@ -210,8 +238,8 @@ rtems_device_driver termios_test_driver_open(
rtems_status_code sc;
rtems_libio_open_close_args_t *args = arg;
static const rtems_termios_callbacks Callbacks = {
- NULL, /* firstOpen */
- NULL, /* lastClose */
+ first_open, /* firstOpen */
+ last_close, /* lastClose */
#if defined(TASK_DRIVEN)
termios_test_driver_inbyte_nonblocking,/* pollRead */
#else
More information about the vc
mailing list