|
Kmods SIG |
9e3ffb |
From 8b0c471773819c8201dc0b0123e1580639ee1570 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
9e3ffb |
From: Tetsuhiro Kohada <kohada.t2@gmail.com>
|
|
Kmods SIG |
9e3ffb |
Date: Wed, 24 Jun 2020 09:54:54 +0900
|
|
Kmods SIG |
9e3ffb |
Subject: [Backport 8b0c47177381] exfat: add error check when updating
|
|
Kmods SIG |
9e3ffb |
dir-entries
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
Add error check when synchronously updating dir-entries.
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
Suggested-by: Sungjong Seo <sj1557.seo@samsung.com>
|
|
Kmods SIG |
9e3ffb |
Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com>
|
|
Kmods SIG |
9e3ffb |
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
|
|
Kmods SIG |
9e3ffb |
---
|
|
Kmods SIG |
9e3ffb |
src/dir.c | 3 ++-
|
|
Kmods SIG |
9e3ffb |
src/exfat_fs.h | 2 +-
|
|
Kmods SIG |
9e3ffb |
src/file.c | 5 ++++-
|
|
Kmods SIG |
9e3ffb |
src/inode.c | 9 +++++----
|
|
Kmods SIG |
9e3ffb |
4 files changed, 12 insertions(+), 7 deletions(-)
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
diff --git a/src/dir.c b/src/dir.c
|
|
Kmods SIG |
9e3ffb |
index 542f1a5ab56fd60a2498f4437c85875cb07e9ef2..573659bfbc5542f20d1181e95ef292f341aab0d6 100644
|
|
Kmods SIG |
9e3ffb |
--- a/src/dir.c
|
|
Kmods SIG |
9e3ffb |
+++ b/src/dir.c
|
|
Kmods SIG |
9e3ffb |
@@ -604,7 +604,7 @@ void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es)
|
|
Kmods SIG |
9e3ffb |
es->modified = true;
|
|
Kmods SIG |
9e3ffb |
}
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
-void exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
|
|
Kmods SIG |
9e3ffb |
+int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
|
|
Kmods SIG |
9e3ffb |
{
|
|
Kmods SIG |
9e3ffb |
int i, err = 0;
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
@@ -617,6 +617,7 @@ void exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
|
|
Kmods SIG |
9e3ffb |
else
|
|
Kmods SIG |
9e3ffb |
brelse(es->bh[i]);
|
|
Kmods SIG |
9e3ffb |
kfree(es);
|
|
Kmods SIG |
9e3ffb |
+ return err;
|
|
Kmods SIG |
9e3ffb |
}
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
static int exfat_walk_fat_chain(struct super_block *sb,
|
|
Kmods SIG |
9e3ffb |
diff --git a/src/exfat_fs.h b/src/exfat_fs.h
|
|
Kmods SIG |
9e3ffb |
index af0f526eece7bd05caa6a1b7fae28701776df5ed..cb51d6e831990f13413267f4fa0a04c3a6176380 100644
|
|
Kmods SIG |
9e3ffb |
--- a/src/exfat_fs.h
|
|
Kmods SIG |
9e3ffb |
+++ b/src/exfat_fs.h
|
|
Kmods SIG |
9e3ffb |
@@ -460,7 +460,7 @@ struct exfat_dentry *exfat_get_dentry_cached(struct exfat_entry_set_cache *es,
|
|
Kmods SIG |
9e3ffb |
int num);
|
|
Kmods SIG |
9e3ffb |
struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
|
|
Kmods SIG |
9e3ffb |
struct exfat_chain *p_dir, int entry, unsigned int type);
|
|
Kmods SIG |
9e3ffb |
-void exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync);
|
|
Kmods SIG |
9e3ffb |
+int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync);
|
|
Kmods SIG |
9e3ffb |
int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir);
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
/* inode.c */
|
|
Kmods SIG |
9e3ffb |
diff --git a/src/file.c b/src/file.c
|
|
Kmods SIG |
9e3ffb |
index a6a063830edcb68944e55fe7308dee1312463b15..6bdabfd4b13426a1965a0e90598a3f5a2821bbe9 100644
|
|
Kmods SIG |
9e3ffb |
--- a/src/file.c
|
|
Kmods SIG |
9e3ffb |
+++ b/src/file.c
|
|
Kmods SIG |
9e3ffb |
@@ -154,6 +154,7 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
|
|
Kmods SIG |
9e3ffb |
struct timespec64 ts;
|
|
Kmods SIG |
9e3ffb |
struct exfat_dentry *ep, *ep2;
|
|
Kmods SIG |
9e3ffb |
struct exfat_entry_set_cache *es;
|
|
Kmods SIG |
9e3ffb |
+ int err;
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
es = exfat_get_dentry_set(sb, &(ei->dir), ei->entry,
|
|
Kmods SIG |
9e3ffb |
ES_ALL_ENTRIES);
|
|
Kmods SIG |
9e3ffb |
@@ -188,7 +189,9 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
|
|
Kmods SIG |
9e3ffb |
}
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
exfat_update_dir_chksum_with_entry_set(es);
|
|
Kmods SIG |
9e3ffb |
- exfat_free_dentry_set(es, inode_needs_sync(inode));
|
|
Kmods SIG |
9e3ffb |
+ err = exfat_free_dentry_set(es, inode_needs_sync(inode));
|
|
Kmods SIG |
9e3ffb |
+ if (err)
|
|
Kmods SIG |
9e3ffb |
+ return err;
|
|
Kmods SIG |
9e3ffb |
}
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
/* cut off from the FAT chain */
|
|
Kmods SIG |
9e3ffb |
diff --git a/src/inode.c b/src/inode.c
|
|
Kmods SIG |
9e3ffb |
index cf9ca6c4d046eed63e8658d7216e2fedbd89cf22..f0160a7892a815cf22a0e495db104a9ebea35615 100644
|
|
Kmods SIG |
9e3ffb |
--- a/src/inode.c
|
|
Kmods SIG |
9e3ffb |
+++ b/src/inode.c
|
|
Kmods SIG |
9e3ffb |
@@ -77,8 +77,7 @@ static int __exfat_write_inode(struct inode *inode, int sync)
|
|
Kmods SIG |
9e3ffb |
ep2->dentry.stream.size = ep2->dentry.stream.valid_size;
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
exfat_update_dir_chksum_with_entry_set(es);
|
|
Kmods SIG |
9e3ffb |
- exfat_free_dentry_set(es, sync);
|
|
Kmods SIG |
9e3ffb |
- return 0;
|
|
Kmods SIG |
9e3ffb |
+ return exfat_free_dentry_set(es, sync);
|
|
Kmods SIG |
9e3ffb |
}
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
int exfat_write_inode(struct inode *inode, struct writeback_control *wbc)
|
|
Kmods SIG |
9e3ffb |
@@ -222,6 +221,7 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
|
|
Kmods SIG |
9e3ffb |
if (ei->dir.dir != DIR_DELETED && modified) {
|
|
Kmods SIG |
9e3ffb |
struct exfat_dentry *ep;
|
|
Kmods SIG |
9e3ffb |
struct exfat_entry_set_cache *es;
|
|
Kmods SIG |
9e3ffb |
+ int err;
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
es = exfat_get_dentry_set(sb, &(ei->dir), ei->entry,
|
|
Kmods SIG |
9e3ffb |
ES_ALL_ENTRIES);
|
|
Kmods SIG |
9e3ffb |
@@ -240,8 +240,9 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
|
|
Kmods SIG |
9e3ffb |
ep->dentry.stream.valid_size;
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
exfat_update_dir_chksum_with_entry_set(es);
|
|
Kmods SIG |
9e3ffb |
- exfat_free_dentry_set(es, inode_needs_sync(inode));
|
|
Kmods SIG |
9e3ffb |
-
|
|
Kmods SIG |
9e3ffb |
+ err = exfat_free_dentry_set(es, inode_needs_sync(inode));
|
|
Kmods SIG |
9e3ffb |
+ if (err)
|
|
Kmods SIG |
9e3ffb |
+ return err;
|
|
Kmods SIG |
9e3ffb |
} /* end of if != DIR_DELETED */
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
inode->i_blocks +=
|
|
Kmods SIG |
9e3ffb |
--
|
|
Kmods SIG |
9e3ffb |
2.31.1
|
|
Kmods SIG |
9e3ffb |
|