From: Yichong Chen <chenyichong@uniontech.com>
To: linkinjeon@kernel.org, sj1557.seo@samsung.com
Cc: yuezhang.mo@sony.com, exfat@lists.linux.dev,
linux-kernel@vger.kernel.org,
Yichong Chen <chenyichong@uniontech.com>
Subject: [PATCH] exfat: free new directory cluster if zeroing fails
Date: Tue, 28 Jul 2026 12:29:23 +0800 [thread overview]
Message-ID: <20260728042923.408237-1-chenyichong@uniontech.com> (raw)
exfat_alloc_new_dir() allocates a cluster for a new directory before
zeroing it. If exfat_zeroed_cluster() fails, the function returns the
error but leaves the allocated cluster in use.
Free the newly allocated cluster before returning the zeroing error.
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
fs/exfat/dir.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index 4fd4ec52b8c0..8d2ae6e33cbf 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -299,7 +299,13 @@ int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu)
if (ret)
return ret;
- return exfat_zeroed_cluster(inode, clu->dir);
+ ret = exfat_zeroed_cluster(inode, clu->dir);
+ if (ret) {
+ exfat_free_cluster(inode, clu);
+ return ret;
+ }
+
+ return 0;
}
int exfat_calc_num_entries(struct exfat_uni_name *p_uniname)
--
2.51.0
next reply other threads:[~2026-07-28 4:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 4:29 Yichong Chen [this message]
2026-07-28 8:51 ` Namjae Jeon
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=20260728042923.408237-1-chenyichong@uniontech.com \
--to=chenyichong@uniontech.com \
--cc=exfat@lists.linux.dev \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sj1557.seo@samsung.com \
--cc=yuezhang.mo@sony.com \
/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®