public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: avoid to access uninitialized block_cluster
@ 2023-03-20 21:21 Kemeng Shi
  2023-03-23 14:18 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Kemeng Shi @ 2023-03-20 21:21 UTC (permalink / raw)
  To: tytso, adilger.kernel, linux-ext4, linux-kernel; +Cc: error27, jack, shikemeng

If inode bitmap block and block bitmap block are in different group,
there is a risk to access uninitialized block_cluster in
ext4_num_overhead_clusters. Initialize block_cluster to -1 to fix this.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/202303171446.eLEhZzAu-lkp@intel.com/
Fixes: e3c70113e2cb ("ext4: improve inode table blocks counting in ext4_num_overhead_clusters")
---
 fs/ext4/balloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 49fdb758b0e4..094269488183 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -89,7 +89,7 @@ static unsigned ext4_num_overhead_clusters(struct super_block *sb,
 					   struct ext4_group_desc *gdp)
 {
 	unsigned base_clusters, num_clusters;
-	int block_cluster, inode_cluster;
+	int block_cluster = -1, inode_cluster;
 	int itbl_cluster_start = -1, itbl_cluster_end = -1;
 	ext4_fsblk_t start = ext4_group_first_block_no(sb, block_group);
 	ext4_fsblk_t end = start + EXT4_BLOCKS_PER_GROUP(sb) - 1;
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-23 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-20 21:21 [PATCH] ext4: avoid to access uninitialized block_cluster Kemeng Shi
2023-03-23 14:18 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox