lkml.org 
[lkml]   [2021]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] ubifs: Remove a redundant null check on pointer lp
From
Date
在 2021/6/21 23:22, Colin King 写道:
> From: Colin Ian King <colin.king@canonical.com>
>
> An earlier fix to replace an IS_ERR check on lp with a null check
> on lp didn't remove a following null check on lp. The second null
> check is redundant and can be removed.
>
> Addresses-Coverity: ("Logically dead code")
> Fixes: c770cd5190ba ("ubifs: fix an IS_ERR() vs NULL check")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> fs/ubifs/gc.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
> index 7cc22d7317ea..465beea52176 100644
> --- a/fs/ubifs/gc.c
> +++ b/fs/ubifs/gc.c
> @@ -899,8 +899,6 @@ int ubifs_gc_start_commit(struct ubifs_info *c)
> err = -ENOMEM;
> goto out;
> }
Hi Colin,
I just found out about it today thanks to your patch. Commit
c770cd5190ba ("ubifs: fix an IS_ERR() vs NULL check") did import a new
problem that ubifs_gc_start_commit() may return -ENOMEM while syncing fs.
I guess ubifs_fast_find_frdi_idx() return NULL pointer is the
termination condition in while-loop, which means we cannot get a
freeable index LEB in ubifs_gc_start_commit().

> - if (!lp)
> - break;
> idx_gc = kmalloc(sizeof(struct ubifs_gced_idx_leb), GFP_NOFS);
> if (!idx_gc) {
> err = -ENOMEM;
>
BTW, the following modifications may be what you want?
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);
\
 
 \ /
  Last update: 2021-06-22 04:39    [W:0.219 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site