From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4180EC4743C for ; Tue, 22 Jun 2021 02:38:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E0D06120D for ; Tue, 22 Jun 2021 02:38:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231478AbhFVClM (ORCPT ); Mon, 21 Jun 2021 22:41:12 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:8287 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbhFVClM (ORCPT ); Mon, 21 Jun 2021 22:41:12 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4G89ST0mxYz1BQKK; Tue, 22 Jun 2021 10:33:45 +0800 (CST) Received: from dggema761-chm.china.huawei.com (10.1.198.203) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Tue, 22 Jun 2021 10:38:53 +0800 Received: from [10.174.178.46] (10.174.178.46) by dggema761-chm.china.huawei.com (10.1.198.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 22 Jun 2021 10:38:53 +0800 Subject: Re: [PATCH] ubifs: Remove a redundant null check on pointer lp To: Colin King , Richard Weinberger , Dan Carpenter , CC: , References: <20210621152249.20901-1-colin.king@canonical.com> From: Zhihao Cheng Message-ID: Date: Tue, 22 Jun 2021 10:38:52 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20210621152249.20901-1-colin.king@canonical.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.46] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggema761-chm.china.huawei.com (10.1.198.203) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: kernel-janitors@vger.kernel.org ÔÚ 2021/6/21 23:22, Colin King дµÀ: > From: Colin Ian King > > 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 > --- > 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);