linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <richard@nod.at>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<dan.carpenter@oracle.com>, <chengzhihao1@huawei.com>,
	<yukuai3@huawei.com>
Subject: [PATCH -next] ubifs: ubifs_gc_start_commit: Fix error check for lp pointer
Date: Wed, 23 Jun 2021 09:21:46 +0800	[thread overview]
Message-ID: <20210623012146.1418360-1-chengzhihao1@huawei.com> (raw)

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


                 reply	other threads:[~2021-06-23  1:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210623012146.1418360-1-chengzhihao1@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).