]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs/ntfs3: Add NULL ptr dereference checking at the end of attr_allocate_frame()
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 28 Nov 2023 08:09:34 +0000 (11:09 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:21:46 +0000 (13:21 +0100)
[ Upstream commit aaab47f204aaf47838241d57bf8662c8840de60a ]

It is preferable to exit through the out: label because
internal debugging functions are located there.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ntfs3/attrib.c

index 1d5ac2164d94f247c6a533dee4e4754aaab98f83..64a6d255c4686fa8329c448fd724d08dd9f72e8d 100644 (file)
@@ -1583,8 +1583,10 @@ repack:
                        le_b = NULL;
                        attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL,
                                              0, NULL, &mi_b);
-                       if (!attr_b)
-                               return -ENOENT;
+                       if (!attr_b) {
+                               err = -ENOENT;
+                               goto out;
+                       }
 
                        attr = attr_b;
                        le = le_b;
@@ -1665,13 +1667,15 @@ ins_ext:
 ok:
        run_truncate_around(run, vcn);
 out:
-       if (new_valid > data_size)
-               new_valid = data_size;
+       if (attr_b) {
+               if (new_valid > data_size)
+                       new_valid = data_size;
 
-       valid_size = le64_to_cpu(attr_b->nres.valid_size);
-       if (new_valid != valid_size) {
-               attr_b->nres.valid_size = cpu_to_le64(valid_size);
-               mi_b->dirty = true;
+               valid_size = le64_to_cpu(attr_b->nres.valid_size);
+               if (new_valid != valid_size) {
+                       attr_b->nres.valid_size = cpu_to_le64(valid_size);
+                       mi_b->dirty = true;
+               }
        }
 
        return err;