[Devel] [PATCH RH7] pfcache: Fix unitialized s_csum_partial

Kirill Tkhai ktkhai at virtuozzo.com
Thu Oct 14 16:26:55 MSK 2021


Since percpu_counter::counters is not allocated,
add and sub operations write to percpu memory
with 0 offset.

In scope of https://jira.sw.ru/browse/PSBM-134639
Fixes: 1204e364ca05 "pfcache: add hashed peers for ext4"
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/ext4/super.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 810556737675..2d7c1d7c4190 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4540,7 +4540,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	sbi->s_err_report.data = (unsigned long) sb;
 
 	err = percpu_counter_init(&sbi->s_extent_cache_cnt, 0, GFP_KERNEL);
-	if (err)
+	if (!err)
 		err = percpu_counter_init(&sbi->s_csum_partial, 0, GFP_KERNEL);
 	if (!err)
 		err = percpu_counter_init(&sbi->s_csum_complete, 0, GFP_KERNEL);




More information about the Devel mailing list