* [PATCH 1/1] fat: restore original value when fat_ent_write failed
@ 2026-05-25 8:56 Ren Wei
2026-06-03 6:20 ` OGAWA Hirofumi
0 siblings, 1 reply; 2+ messages in thread
From: Ren Wei @ 2026-05-25 8:56 UTC (permalink / raw)
To: linux-kernel
Cc: OGAWA Hirofumi, Yuan Tan, Yifan Wu, Juefei Pu, Xin Liu, Yemu Lu,
Ren Wei
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>
---
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)
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] fat: restore original value when fat_ent_write failed
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
0 siblings, 0 replies; 2+ messages in thread
From: OGAWA Hirofumi @ 2026-06-03 6:20 UTC (permalink / raw)
To: Andrew Morton
Cc: Ren Wei, linux-kernel, Yuan Tan, Yifan Wu, Juefei Pu, Xin Liu,
Yemu Lu
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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-03 6:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.