]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntfs: Remove impossible condition
authorEthan Tidmore <ethantidmore06@gmail.com>
Thu, 26 Feb 2026 04:03:55 +0000 (22:03 -0600)
committerNamjae Jeon <linkinjeon@kernel.org>
Thu, 26 Feb 2026 09:26:12 +0000 (18:26 +0900)
The variable name_len is checked to see if it's larger than the macro
NTFS_MAX_NAME_LEN however this condition is impossible because name_len
is of type u8 and NTFS_MAX_NAME_LEN is hardcoded to be 255.

Detected by Smatch:
fs/ntfs/namei.c:1175 __ntfs_link() warn:
impossible condition '(name_len > 255) => (0-255 > 255)'

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/namei.c

index cecfaabfbfe7f4ecfb812a6d75679a56da36fc22..2952b377dda2398a8a234a60e821128bc8041ef4 100644 (file)
@@ -1172,10 +1172,7 @@ static int __ntfs_link(struct ntfs_inode *ni, struct ntfs_inode *dir_ni,
 
        /* Create FILE_NAME attribute. */
        fn_len = sizeof(struct file_name_attr) + name_len * sizeof(__le16);
-       if (name_len > NTFS_MAX_NAME_LEN) {
-               err = -EIO;
-               goto err_out;
-       }
+
        fn = kzalloc(fn_len, GFP_NOFS);
        if (!fn) {
                err = -ENOMEM;