jffs2: fix use of uninitialized variable
PATCH 1/1 jffs2: fix use of uninitialized variable
From: Qingfang Deng <[email protected]>
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.
--- fs/jffs2/erase.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/jffs2/erase.c +3 -4
@@ -338,10 +338,9 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl }while (--retlen);mtd_unpoint (c->mtd, jeb->offset, c->sector_size);if (retlen) { -pr_warn ("Newly-erased block contained word 0x%lx at offset 0x%08tx\n" , - *wordebuf, - jeb->offset + - c->sector_size-retlen *sizeof (*wordebuf)); + *bad_offset = jeb->offset + c->sector_size - retlen *sizeof (*wordebuf); +pr_warn ("Newly-erased block contained word 0x%lx at offset 0x%08x\n" , + *wordebuf, *bad_offset);return -EIO ; }return 0 ;
Signature · 1 line
2.34.1
Quoted 20 lines · Qingfang Deng
From: Qingfang Deng <[email protected]>
When building the kernel with -Wmaybe-uninitialized, the compiler reports this warning:
In function '
jffs2_mark_erased_block',
inlined from 'jffs2_erase_pending_blocks' atfs/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_blockscan return-EIOwithout initializingbad_offset, which is later used at the filebad label injffs2_mark_erased_block.
Fix it by initializing this variable.
Quoted 6 lines
Fixes 8a0f572397ca ("[JFFS2] Return values of jffs2_block_check_erase error paths")Signed-off-by Qingfang Deng <[email protected]>--- fs/jffs2/erase.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Quoted 19 lines
fs/jffs2/erase.c +3
-4@@ -338,10 +338,9 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl }while (--retlen);mtd_unpoint (c->mtd, jeb->offset, c->sector_size);if (retlen) { -pr_warn ("Newly-erased block contained word 0x%lx at offset 0x%08tx\n" , - *wordebuf, - jeb->offset + - c->sector_size-retlen *sizeof (*wordebuf)); + *bad_offset = jeb->offset + c->sector_size - retlen *sizeof (*wordebuf); +pr_warn ("Newly-erased block contained word 0x%lx at offset 0x%08x\n" , + *wordebuf, *bad_offset);return -EIO ; }return 0 ;
Any update on this?
Richard Weinberger
maintainer----- Ursprüngliche Mail -----
Quoted 8 lines
Von: "Qingfang Deng" <[email protected]>
An: "David Woodhouse" <[email protected]>, "richard" <[email protected]>, "Qingfang Deng" <[email protected]>, "linux-mtd" <[email protected]>, "linux-kernel" <[email protected]>
Gesendet: Dienstag, 12. November 2024 06:46:51
Betreff: Re: [PATCH] jffs2: fix use of uninitialized variableAny update on this?
It's planned for the upcomming merge window.
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/