]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
erofs: fix error handling in z_erofs_init_decompressor
authorSandeep Dhavale <dhavale@google.com>
Thu, 5 Sep 2024 06:00:25 +0000 (23:00 -0700)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 9 Sep 2024 16:46:34 +0000 (00:46 +0800)
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: 5a7cce827ee9 ("erofs: refine z_erofs_{init,exit}_subsystem()")
Reported-by: liujinbao1 <liujinbao1@xiaomi.com>
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20240905060027.2388893-1-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/decompressor.c

index c2253b6a54164d5b5b16e713aa6ec8f6b78bb30b..eb318c7ddd80ed7a4d5a3dfab9881d13fbe478d7 100644 (file)
@@ -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;