From f08c71339c05cb462a32a11e3150d71603340e94 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 16 Mar 2017 11:54:29 +0100 Subject: libio: Fix deadlock in location management Perform a context-dependent deferred location release to avoid a deadlock on the file system instance locks, for example during a chdir(). Close #2936. --- cpukit/libcsupport/src/sup_fs_location.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cpukit/libcsupport/src/sup_fs_location.c') diff --git a/cpukit/libcsupport/src/sup_fs_location.c b/cpukit/libcsupport/src/sup_fs_location.c index ddda4d15eb..c8956f26cf 100644 --- a/cpukit/libcsupport/src/sup_fs_location.c +++ b/cpukit/libcsupport/src/sup_fs_location.c @@ -105,7 +105,7 @@ void rtems_filesystem_global_location_assign( *lhs_global_loc_ptr = rhs_global_loc; rtems_filesystem_mt_entry_unlock(lock_context); - rtems_filesystem_global_location_release(lhs_global_loc); + rtems_filesystem_global_location_release(lhs_global_loc, true); } static void release_with_count( @@ -183,10 +183,11 @@ rtems_filesystem_global_location_t *rtems_filesystem_global_location_obtain( } void rtems_filesystem_global_location_release( - rtems_filesystem_global_location_t *global_loc + rtems_filesystem_global_location_t *global_loc, + bool deferred ) { - if (_Thread_Dispatch_is_enabled()) { + if (!deferred) { release_with_count(global_loc, 1); } else { rtems_interrupt_lock_context lock_context; @@ -232,7 +233,7 @@ void rtems_filesystem_do_unmount( rtems_filesystem_mt_lock(); rtems_chain_extract_unprotected(&mt_entry->mt_node); rtems_filesystem_mt_unlock(); - rtems_filesystem_global_location_release(mt_entry->mt_point_node); + rtems_filesystem_global_location_release(mt_entry->mt_point_node, false); (*mt_entry->ops->fsunmount_me_h)(mt_entry); if (mt_entry->unmount_task != 0) { -- cgit v1.2.3