]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntfs: Fix possible deadlock
authorEthan Tidmore <ethantidmore06@gmail.com>
Thu, 26 Feb 2026 16:09:06 +0000 (10:09 -0600)
committerNamjae Jeon <linkinjeon@kernel.org>
Fri, 27 Feb 2026 09:43:43 +0000 (18:43 +0900)
In the error path for ntfs_attr_map_whole_runlist() the lock is not
released.

Add release for lock.

Detected by Smatch:
fs/ntfs/attrib.c:5197 ntfs_non_resident_attr_collapse_range() warn:
inconsistent returns '&ni->runlist.lock'.

Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/ntfs/attrib.c

index 71ad870eceacd3163aa8365ceedd859b66d8f08c..2af45df2aab1330ee4deb3ea3d3b8c17837a5106 100644 (file)
@@ -5124,8 +5124,10 @@ int ntfs_non_resident_attr_collapse_range(struct ntfs_inode *ni, s64 start_vcn,
 
        down_write(&ni->runlist.lock);
        ret = ntfs_attr_map_whole_runlist(ni);
-       if (ret)
+       if (ret) {
+               up_write(&ni->runlist.lock);
                return ret;
+       }
 
        len = min(len, end_vcn - start_vcn);
        for (rl = ni->runlist.rl, dst_cnt = 0; rl && rl->length; rl++)