[PATCH] memfs_ll: fix deadlock in truncate operation
authorLong Li <leo.lilong@huawei.com>
Wed, 16 Jul 2025 01:54:07 +0000 (09:54 +0800)
committerLaszlo Boszormenyi (GCS) <gcs@debian.org>
Wed, 16 Jul 2025 17:27:21 +0000 (17:27 +0000)
Remove redundant mutex lock acquisition in the truncate() method to
prevent deadlock. The issue occurs when memfs_setattr() already holds
the mutex lock and then calls truncate(), which attempts to acquire
the same lock again.

Signed-off-by: Long Li <leo.lilong@huawei.com>
Gbp-Pq: Name memfs_ll-fix-deadlock.patch

example/memfs_ll.cc

index 603885017d4c4e487c0e53dbdf601cecab84f6b8..e5877565b27946d61888e8d13a228e553aa02335 100644 (file)
@@ -197,7 +197,6 @@ class Inode {
 
        void truncate(off_t size)
        {
-               std::lock_guard<std::mutex> lock(mutex);
                std::lock_guard<std::mutex> attr_lock(attr_mutex);
                if (size < content.size()) {
                        content.resize(size);