diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-11-11 14:47:50 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-11-12 08:28:45 +0100 |
commit | 459ebc8397b8cb13a67ebb4cb0b7aa941fbfbf29 (patch) | |
tree | 5564be618520803f238522bd1a60fc560eeb1c98 /testsuites | |
parent | score: Fix race condition on SMP (diff) | |
download | rtems-459ebc8397b8cb13a67ebb4cb0b7aa941fbfbf29.tar.bz2 |
libtests/termios04: Avoid use of freed memory
Diffstat (limited to '')
-rw-r--r-- | testsuites/libtests/termios04/termios_testdriver_intr.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/testsuites/libtests/termios04/termios_testdriver_intr.c b/testsuites/libtests/termios04/termios_testdriver_intr.c index 94ebe28629..53764fb9da 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 |