aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunchul Lee <hyc.lee@gmail.com>2023-05-17 09:49:40 +0900
committerNamjae Jeon <linkinjeon@kernel.org>2023-05-17 11:14:21 +0900
commit6bfcd9f5920ebad7f2168ad2622214fad42b0e4a (patch)
treea3728ea970fe6f42b16ac31120107f1ba16164a2
parent4355a84c3b1edf55561c5ada71e2b4ed309260c7 (diff)
downloadexfatprogs-6bfcd9f5920ebad7f2168ad2622214fad42b0e4a.tar.gz
fsck: fix assertion in exfat_c2o
exfat_c2o() is called with the cluster 0, and fsck is aborted with the stack backtrace below due to the assertion in exfat_c2o(). exfat_c2o write_block exfat_de_iter_flush This is caused by that write_block() could be called for the cluster which is not read yet. Make exfat_c2o is called only when the cluster is dirty. Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r--lib/exfat_dir.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/exfat_dir.c b/lib/exfat_dir.c
index c079403..7c145f4 100644
--- a/lib/exfat_dir.c
+++ b/lib/exfat_dir.c
@@ -35,10 +35,11 @@ static ssize_t write_block(struct exfat_de_iter *iter, unsigned int block)
unsigned int i;
desc = &iter->buffer_desc[block & 0x01];
- device_offset = exfat_c2o(exfat, desc->p_clus) + desc->offset;
for (i = 0; i < iter->read_size / iter->write_size; i++) {
if (desc->dirty[i]) {
+ device_offset = exfat_c2o(exfat, desc->p_clus) +
+ desc->offset;
if (exfat_write(exfat->blk_dev->dev_fd,
desc->buffer + i * iter->write_size,
iter->write_size,