mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Prevent entering an infinite loop when i is 0
@ 2024-08-22  6:27 liujinbao1
  2024-08-22  6:42 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: liujinbao1 @ 2024-08-22  6:27 UTC (permalink / raw)
  To: xiang; +Cc: chao, linux-erofs, linux-kernel, liujinbao1

From: liujinbao1 <liujinbao1@xiaomi.com>

When i=0 and err is not equal to 0,
the while(-1) loop will enter into an
infinite loop. This patch avoids this issue.
---
 fs/erofs/decompressor.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index c2253b6a5416..1b2b8cc7911c 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -539,6 +539,8 @@ 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) {
+			if (!i)
+				return err;
 			while (--i)
 				if (z_erofs_decomp[i])
 					z_erofs_decomp[i]->exit();
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-22  6:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-22  6:27 [PATCH] Prevent entering an infinite loop when i is 0 liujinbao1
2024-08-22  6:42 ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®