summaryrefslogtreecommitdiffstats
path: root/fs/ext2
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-09-21 23:32:33 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-09 14:11:03 +0200
commit21909f9e0995b80579a1fdc1e857ac2fe5067c4d (patch)
tree8865f989ac683b6b11ed284b9a1f16a03c4e6863 /fs/ext2
parentce53b91e974d7b87fe8a457c2431d050466de87e (diff)
downloadlinux-stable-21909f9e0995b80579a1fdc1e857ac2fe5067c4d.tar.gz
linux-stable-21909f9e0995b80579a1fdc1e857ac2fe5067c4d.tar.bz2
linux-stable-21909f9e0995b80579a1fdc1e857ac2fe5067c4d.zip
ext2: fix sleeping in atomic bugs on error
[ Upstream commit 372d1f3e1bfede719864d0d1fbf3146b1e638c88 ] The ext2_error() function syncs the filesystem so it sleeps. The caller is holding a spinlock so it's not allowed to sleep. ext2_statfs() <- disables preempt -> ext2_count_free_blocks() -> ext2_get_group_desc() Fix this by using WARN() to print an error message and a stack trace instead of using ext2_error(). Link: https://lore.kernel.org/r/20210921203233.GA16529@kili Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/balloc.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 33db13365c5e..fc59e0557e50 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -48,10 +48,9 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
struct ext2_sb_info *sbi = EXT2_SB(sb);
if (block_group >= sbi->s_groups_count) {
- ext2_error (sb, "ext2_get_group_desc",
- "block_group >= groups_count - "
- "block_group = %d, groups_count = %lu",
- block_group, sbi->s_groups_count);
+ WARN(1, "block_group >= groups_count - "
+ "block_group = %d, groups_count = %lu",
+ block_group, sbi->s_groups_count);
return NULL;
}
@@ -59,10 +58,9 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
group_desc = block_group >> EXT2_DESC_PER_BLOCK_BITS(sb);
offset = block_group & (EXT2_DESC_PER_BLOCK(sb) - 1);
if (!sbi->s_group_desc[group_desc]) {
- ext2_error (sb, "ext2_get_group_desc",
- "Group descriptor not loaded - "
- "block_group = %d, group_desc = %lu, desc = %lu",
- block_group, group_desc, offset);
+ WARN(1, "Group descriptor not loaded - "
+ "block_group = %d, group_desc = %lu, desc = %lu",
+ block_group, group_desc, offset);
return NULL;
}