Skip to contentSkip to conversation

erofs: fix error handling in z_erofs_init_decompressor

PATCH In review Sandeep Dhavale 3 participants 3 messages Sep 5, 2024 – Sep 9, 2024 EROFS file system

lore
Share & tools
lore

Sandeep Dhavale

author reviewer
#0 lore raw

PATCH v3 1/1 erofs: fix error handling in z_erofs_init_decompressor

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()")

---
v2: https://lore.kernel.org/linux-erofs/[email protected]/
v1: https://lore.kernel.org/linux-erofs/[email protected]/

 fs/erofs/decompressor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/decompressor.c +1 -1
index c2253b6a5416..eb318c7ddd80 100644
@@ -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;
Signature · 1 line
2.46.0.469.g59c65b2a67-goog
Reviewed-by on v3 1/1
#1 lore raw
Quoted 7 lines · Sandeep Dhavale

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()")

Thanks,
Gao Xiang

maintainer Reviewed-by on v3 1/1
#2 lore raw
In reply to Sandeep Dhavale
Quoted 7 lines · Sandeep Dhavale

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()")

Thanks,