From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ren Wei <n05ec@lzu.edu.cn>,
linux-kernel@vger.kernel.org, Yuan Tan <yuantan098@gmail.com>,
Yifan Wu <yifanwucs@gmail.com>,
Juefei Pu <tomapufckgml@gmail.com>, Xin Liu <bird@lzu.edu.cn>,
Yemu Lu <prcups@krgm.moe>
Subject: Re: [PATCH 1/1] fat: restore original value when fat_ent_write failed
Date: Wed, 03 Jun 2026 15:20:41 +0900 [thread overview]
Message-ID: <87pl28i1qe.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <20260525085649.781643-1-n05ec@lzu.edu.cn>
Ren Wei <n05ec@lzu.edu.cn> writes:
> From: Yemu Lu <prcups@krgm.moe>
>
> fat_ent_write() may have committed the new link to the primary FAT
> but then failed on the mirror copy, leaving the chain pointing to
> new_dclus even though the caller will free it. Restore the original
> value to keep the chain consistent.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@kernel.org
> Reported-by: Yuan Tan <yuantan098@gmail.com>
> Reported-by: Yifan Wu <yifanwucs@gmail.com>
> Reported-by: Juefei Pu <tomapufckgml@gmail.com>
> Reported-by: Xin Liu <bird@lzu.edu.cn>
> Signed-off-by: Yemu Lu <prcups@krgm.moe>
> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> ---
> fs/fat/misc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/fat/misc.c b/fs/fat/misc.c
> index 3027ef53af21..710e2e6aa1a5 100644
> --- a/fs/fat/misc.c
> +++ b/fs/fat/misc.c
> @@ -133,7 +133,11 @@ int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster)
> ret = fat_ent_read(inode, &fatent, last);
> if (ret >= 0) {
> int wait = inode_needs_sync(inode);
> + int old = ret;
> +
> ret = fat_ent_write(inode, &fatent, new_dclus, wait);
> + if (ret < 0)
> + fat_ent_write(inode, &fatent, old, wait);
> fatent_brelse(&fatent);
> }
> if (ret < 0)
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2026-06-03 6:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 8:56 [PATCH 1/1] fat: restore original value when fat_ent_write failed Ren Wei
2026-06-03 6:20 ` OGAWA Hirofumi [this message]
2026-06-28 20:27 ` Andrew Morton
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=87pl28i1qe.fsf@mail.parknet.co.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=akpm@linux-foundation.org \
--cc=bird@lzu.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=n05ec@lzu.edu.cn \
--cc=prcups@krgm.moe \
--cc=tomapufckgml@gmail.com \
--cc=yifanwucs@gmail.com \
--cc=yuantan098@gmail.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