linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] ubifs: ubifs_gc_start_commit: Fix error check for lp pointer
@ 2021-06-23  1:21 Zhihao Cheng
  0 siblings, 0 replies; only message in thread
From: Zhihao Cheng @ 2021-06-23  1:21 UTC (permalink / raw)
  To: richard; +Cc: linux-mtd, linux-kernel, dan.carpenter, chengzhihao1, yukuai3

Treating the NULL pointer returned from ubifs_fast_find_frdi_idx() as
ENOMEM will make ubifs_gc_start_commit() fails, which could make ubifs
read-only. Actually a returned NULL pointer is the termination
condition in while-loop in ubifs_gc_start_commit().

Fixes: c770cd5190ba ("ubifs: fix an IS_ERR() vs NULL check")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 fs/ubifs/gc.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 7cc22d7317ea..b1f276599b04 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -895,10 +895,6 @@ int ubifs_gc_start_commit(struct ubifs_info *c)
 	/* Record index freeable LEBs for unmapping after commit */
 	while (1) {
 		lp = ubifs_fast_find_frdi_idx(c);
-		if (!lp) {
-			err = -ENOMEM;
-			goto out;
-		}
 		if (!lp)
 			break;
 		idx_gc = kmalloc(sizeof(struct ubifs_gced_idx_leb), GFP_NOFS);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-23  1:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23  1:21 [PATCH -next] ubifs: ubifs_gc_start_commit: Fix error check for lp pointer Zhihao Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).