mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
fs_lock:Check the nwaiter when deleting a bucket
Summary: Fixed the problem of releasing the bucket prematurely in multi-threaded flock scenarios. A thread setlk B thread setlk_wait A thread releases lock but fails to determine if nwaiter causes the bucket to be released prematurely post B thread causes crash due to heap use after free https://github.com/apache/nuttx/issues/13821 Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
+1
-1
@@ -237,7 +237,7 @@ static void file_lock_delete_bucket(FAR struct file_lock_bucket_s *bucket,
|
||||
* released
|
||||
*/
|
||||
|
||||
if (list_is_empty(&bucket->list))
|
||||
if (list_is_empty(&bucket->list) && bucket->nwaiter == 0)
|
||||
{
|
||||
/* At this point, the file has no lock information context, so we can
|
||||
* remove it from the hash table, and the return result is 0 or 1 means
|
||||
|
||||
Reference in New Issue
Block a user