mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: <ntfs3@lists.linux.dev>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	<linux-fsdevel@vger.kernel.org>
Subject: [PATCH 01/10] fs/ntfs3: Correct checking while generating attr_list
Date: Mon, 8 May 2023 16:36:03 +0400	[thread overview]
Message-ID: <ba9a25e5-89b1-cc25-6d2c-af86ca33e25b@paragon-software.com> (raw)
In-Reply-To: <b21a4bc9-166d-2631-d73b-cb4e802ff69e@paragon-software.com>

Correct slightly previous commit:
Enhance sanity check while generating attr_list

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
  fs/ntfs3/frecord.c | 25 ++++++++++---------------
  1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 50214b77c6a3..66f3341c65ec 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -813,10 +813,8 @@ int ni_create_attr_list(struct ntfs_inode *ni)
       * Looks like one record_size is always enough.
       */
      le = kmalloc(al_aligned(rs), GFP_NOFS);
-    if (!le) {
-        err = -ENOMEM;
-        goto out;
-    }
+    if (!le)
+        return -ENOMEM;

      mi_get_ref(&ni->mi, &le->ref);
      ni->attr_list.le = le;
@@ -865,14 +863,14 @@ int ni_create_attr_list(struct ntfs_inode *ni)

          if (to_free > free_b) {
              err = -EINVAL;
-            goto out1;
+            goto out;
          }
      }

      /* Allocate child MFT. */
      err = ntfs_look_free_mft(sbi, &rno, is_mft, ni, &mi);
      if (err)
-        goto out1;
+        goto out;

      err = -EINVAL;
      /* Call mi_remove_attr() in reverse order to keep pointers 
'arr_move' valid. */
@@ -884,7 +882,7 @@ int ni_create_attr_list(struct ntfs_inode *ni)
          attr = mi_insert_attr(mi, b->type, Add2Ptr(b, name_off),
                        b->name_len, asize, name_off);
          if (!attr)
-            goto out1;
+            goto out;

          mi_get_ref(mi, &le_b[nb]->ref);
          le_b[nb]->id = attr->id;
@@ -895,19 +893,19 @@ int ni_create_attr_list(struct ntfs_inode *ni)

          /* Remove from primary record. */
          if (!mi_remove_attr(NULL, &ni->mi, b))
-            goto out1;
+            goto out;

          if (to_free <= asize)
              break;
          to_free -= asize;
          if (!nb)
-            goto out1;
+            goto out;
      }

      attr = mi_insert_attr(&ni->mi, ATTR_LIST, NULL, 0,
                    lsize + SIZEOF_RESIDENT, SIZEOF_RESIDENT);
      if (!attr)
-        goto out1;
+        goto out;

      attr->non_res = 0;
      attr->flags = 0;
@@ -921,16 +919,13 @@ int ni_create_attr_list(struct ntfs_inode *ni)
      ni->attr_list.dirty = false;

      mark_inode_dirty(&ni->vfs_inode);
-    goto out;
+    return 0;

-out1:
+out:
      kfree(ni->attr_list.le);
      ni->attr_list.le = NULL;
      ni->attr_list.size = 0;
      return err;
-
-out:
-    return 0;
  }

  /*
-- 
2.34.1


  reply	other threads:[~2023-05-08 12:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08 12:35 [PATCH 00/10] Refactoring and bugfix Konstantin Komarov
2023-05-08 12:36 ` Konstantin Komarov [this message]
2023-05-08 12:36 ` [PATCH 02/10] fs/ntfs3: Fix ntfs_atomic_open Konstantin Komarov
2023-05-08 12:36 ` [PATCH 03/10] fs/ntfs3: Mark ntfs dirty when on-disk struct is corrupted Konstantin Komarov
2023-05-08 12:37 ` [PATCH 04/10] fs/ntfs3: Alternative boot if primary boot " Konstantin Komarov
2023-05-08 12:38 ` [PATCH 05/10] fs/ntfs3: Do not update primary boot in ntfs_init_from_boot() Konstantin Komarov
2023-05-08 12:38 ` [PATCH 06/10] fs/ntfs3: Code formatting Konstantin Komarov
2023-05-08 12:38 ` [PATCH 07/10] fs/ntfs3: Code refactoring Konstantin Komarov
2023-05-08 12:39 ` [PATCH 08/10] fs/ntfs3: Add ability to format new mft records with bigger/smaller header Konstantin Komarov
2023-05-08 12:39 ` [PATCH 09/10] fs/ntfs3: Fix endian problem Konstantin Komarov
2023-05-08 12:40 ` [PATCH 10/10] fs/ntfs3: Add support /proc/fs/ntfs3/<dev>/volinfo and /proc/fs/ntfs3/<dev>/label Konstantin Komarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba9a25e5-89b1-cc25-6d2c-af86ca33e25b@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®