mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ntfs: Fix error handling in __ntfs_create()
@ 2026-10-26 19:43 Bart Van Assche
  2026-10-27  0:23 ` Hyunchul Lee
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2026-10-26 19:43 UTC (permalink / raw)
  To: Namjae Jeon, Hyunchul Lee; +Cc: ntfs, linux-kernel, Bart Van Assche

In __ntfs_create(), if ntfs_init_acl() fails before
ntfs_mft_record_alloc() is called, jumping to err_out frees MFT record
0 ($MFT), unmaps an unmapped record and unlocks the unheld
&dir_ni->mrec_lock and &ni->mrec_lock mutexes. Call iput(vi) and
return ERR_PTR(err) directly instead, matching the
ntfs_mft_record_alloc() failure path right below it.

Fixes: af0db57d4293 ("ntfs: update inode operations")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fs/ntfs/namei.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 62b01646c262..b46fe44b63b5 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -472,8 +472,10 @@ static struct ntfs_inode *__ntfs_create(const struct mnt_idmap *idmap, struct in
 #ifdef CONFIG_NTFS_FS_POSIX_ACL
 	if (!S_ISLNK(mode) && (sb->s_flags & SB_POSIXACL)) {
 		err = ntfs_init_acl(idmap, vi, dir);
-		if (err)
-			goto err_out;
+		if (err) {
+			iput(vi);
+			return ERR_PTR(err);
+		}
 	} else
 #endif
 	{

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ntfs: Fix error handling in __ntfs_create()
  2026-10-26 19:43 [PATCH] ntfs: Fix error handling in __ntfs_create() Bart Van Assche
@ 2026-10-27  0:23 ` Hyunchul Lee
  0 siblings, 0 replies; 2+ messages in thread
From: Hyunchul Lee @ 2026-10-27  0:23 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Namjae Jeon, ntfs, linux-kernel

On Mon, Oct 26, 2026 at 12:43:00PM -0700, Bart Van Assche wrote:
> In __ntfs_create(), if ntfs_init_acl() fails before
> ntfs_mft_record_alloc() is called, jumping to err_out frees MFT record
> 0 ($MFT), unmaps an unmapped record and unlocks the unheld
> &dir_ni->mrec_lock and &ni->mrec_lock mutexes. Call iput(vi) and
> return ERR_PTR(err) directly instead, matching the
> ntfs_mft_record_alloc() failure path right below it.
> 
> Fixes: af0db57d4293 ("ntfs: update inode operations")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Looks good to me.

Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>

-- 
Thanks,
Hyunchul

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-27  0:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 19:43 [PATCH] ntfs: Fix error handling in __ntfs_create() Bart Van Assche
2026-10-27  0:23 ` Hyunchul Lee

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®