Skip to content

Commit

Permalink
erofs: fix error handling in z_erofs_init_decompressor
Browse files Browse the repository at this point in the history
If we get a failure at the first decompressor init (i = 0),
the clean up while loop could enter infinite loop due to wrong while
check. Check the value of i now to see if we need any clean up at all.

Fixes: 5a7cce8 ("erofs: refine z_erofs_{init,exit}_subsystem()")
Reported-by: liujinbao1 <[email protected]>
Signed-off-by: Sandeep Dhavale <[email protected]>
Reviewed-by: Gao Xiang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Gao Xiang <[email protected]>
  • Loading branch information
Sandeep Dhavale authored and hsiangkao committed Sep 5, 2024
1 parent 73ea175 commit 639cabc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/erofs/decompressor.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ int __init z_erofs_init_decompressor(void)
for (i = 0; i < Z_EROFS_COMPRESSION_MAX; ++i) {
err = z_erofs_decomp[i] ? z_erofs_decomp[i]->init() : 0;
if (err) {
while (--i)
while (i--)
if (z_erofs_decomp[i])
z_erofs_decomp[i]->exit();
return err;
Expand Down

0 comments on commit 639cabc

Please sign in to comment.