forked from Imagelibrary/rtems
libtests/termios04: Avoid use of freed memory
This commit is contained in:
@@ -181,8 +181,6 @@ rtems_device_driver termios_test_driver_initialize(
|
|||||||
void *arg
|
void *arg
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
rtems_status_code status;
|
|
||||||
|
|
||||||
rtems_termios_initialize();
|
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 );
|
(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);
|
status = rtems_timer_create(rtems_build_name('T', 'M', 'R', 'X'), &Rx_Timer);
|
||||||
if ( status )
|
if ( status != RTEMS_SUCCESSFUL )
|
||||||
rtems_fatal_error_occurred(1);
|
rtems_fatal_error_occurred(1);
|
||||||
|
|
||||||
status = rtems_timer_create(rtems_build_name('T', 'M', 'T', 'X'), &Tx_Timer);
|
status = rtems_timer_create(rtems_build_name('T', 'M', 'T', 'X'), &Tx_Timer);
|
||||||
if ( status )
|
if ( status != RTEMS_SUCCESSFUL )
|
||||||
rtems_fatal_error_occurred(1);
|
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(
|
rtems_device_driver termios_test_driver_open(
|
||||||
@@ -210,8 +238,8 @@ rtems_device_driver termios_test_driver_open(
|
|||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
rtems_libio_open_close_args_t *args = arg;
|
rtems_libio_open_close_args_t *args = arg;
|
||||||
static const rtems_termios_callbacks Callbacks = {
|
static const rtems_termios_callbacks Callbacks = {
|
||||||
NULL, /* firstOpen */
|
first_open, /* firstOpen */
|
||||||
NULL, /* lastClose */
|
last_close, /* lastClose */
|
||||||
#if defined(TASK_DRIVEN)
|
#if defined(TASK_DRIVEN)
|
||||||
termios_test_driver_inbyte_nonblocking,/* pollRead */
|
termios_test_driver_inbyte_nonblocking,/* pollRead */
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user