Skip to contentSkip to conversation

fs/ntfs3: unlock on error in attr_insert_range()

PATCH Applied Dan Carpenter 2 participants 2 messages Jun 30, 2022 – Jul 5, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/ntfs3: unlock on error in attr_insert_range()

This error path needs to call up_write(&ni->file.run_lock) and do some other clean up before returning.

Fixes aa30eccb24e5 ("fs/ntfs3: Fallocate (FALLOC_FL_INSERT_RANGE) implementation")

---
This patch is based on static analysis. I'm pretty sure that unlocking is the correct thing and, of course, I try to not send patches that introduce bugs. But it's untested and needs to be reviewed extra carefully.

 fs/ntfs3/attrib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ntfs3/attrib.c +4 -2
index 86e688b95ad5..3e9aefcb3e6c 100644
@@ -2153,8 +2153,10 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
 		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;
+		}
 		if (!attr_b->non_res) {
 			err = -EINVAL;
 			goto out;
Signature · 1 line
2.35.1
maintainer Applied
#1 lore raw
Quoted 21 lines · Dan Carpenter

This error path needs to call up_write(&ni->file.run_lock) and do some other clean up before returning.

Fixes aa30eccb24e5 ("fs/ntfs3: Fallocate (FALLOC_FL_INSERT_RANGE) implementation")

---
This patch is based on static analysis. I'm pretty sure that unlocking is the correct thing and, of course, I try to not send patches that introduce bugs. But it's untested and needs to be reviewed extra carefully.

  fs/ntfs3/attrib.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
fs/ntfs3/attrib.c +0 -0
index 86e688b95ad5..3e9aefcb3e6c 100644
@@ -2153,8 +2153,10 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
  		le_b = NULL;
  		attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL,

fs/ntfs3/attrib.c int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes) · line 2162

Quoted 10 lines
fs/ntfs3/attrib.c +4 -2
  				      &mi_b);
-		if (!attr_b)
-			return -ENOENT;
+		if (!attr_b) {
+			err = -ENOENT;
+			goto out;
+		}
  		if (!attr_b->non_res) {
  			err = -EINVAL;
  			goto out;

Applied, thanks!