Skip to content

Commit 3ba44ee

Browse files
LGA1150richardweinberger
authored andcommitted
jffs2: fix use of uninitialized variable
When building the kernel with -Wmaybe-uninitialized, the compiler reports this warning: In function 'jffs2_mark_erased_block', inlined from 'jffs2_erase_pending_blocks' at fs/jffs2/erase.c:116:4: fs/jffs2/erase.c:474:9: warning: 'bad_offset' may be used uninitialized [-Wmaybe-uninitialized] 474 | jffs2_erase_failed(c, jeb, bad_offset); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/jffs2/erase.c: In function 'jffs2_erase_pending_blocks': fs/jffs2/erase.c:402:18: note: 'bad_offset' was declared here 402 | uint32_t bad_offset; | ^~~~~~~~~~ When mtd->point() is used, jffs2_erase_pending_blocks can return -EIO without initializing bad_offset, which is later used at the filebad label in jffs2_mark_erased_block. Fix it by initializing this variable. Fixes: 8a0f572 ("[JFFS2] Return values of jffs2_block_check_erase error paths") Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 3c90e90 commit 3ba44ee

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/jffs2/erase.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,9 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
338338
} while(--retlen);
339339
mtd_unpoint(c->mtd, jeb->offset, c->sector_size);
340340
if (retlen) {
341-
pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08tx\n",
342-
*wordebuf,
343-
jeb->offset +
344-
c->sector_size-retlen * sizeof(*wordebuf));
341+
*bad_offset = jeb->offset + c->sector_size - retlen * sizeof(*wordebuf);
342+
pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08x\n",
343+
*wordebuf, *bad_offset);
345344
return -EIO;
346345
}
347346
return 0;

0 commit comments

Comments
 (0)