Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4314446pxj; Mon, 21 Jun 2021 19:40:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzR/Bhc4GD8wTWNdqGvEaydzX6tAT8GS4kXJmte4yTWnM06a9A6bHMgREqz/8umZGI8SzQ4 X-Received: by 2002:a92:9509:: with SMTP id y9mr984814ilh.18.1624329634360; Mon, 21 Jun 2021 19:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624329634; cv=none; d=google.com; s=arc-20160816; b=WO0ERKpDfq29fjOLCsEhi359HrdmV/AbZ8pXZ/zi8aj6N/nsXNjFxoqJgIG41eYA7b ShPqC8UF5bXfXW1Ku+t4ITchspzj55VKZQo1OCKtxW/RObnfvLftenkRT06TWA/MMxi5 OllQnSpwiBrOzxUjP4LYku1bHdLiZGk8MYLIrPLVt3qbtWtDLtdMaqJCwfPDfopK4zam fBgQ3StEWIaRCS2YSfFov8yRECq7chaXb1tLtf4xpm6gJGaP2SFmYRgIu29fZKXFX760 xraCEPYB2KEMpevaOuKy7rb2U51nqhJQ74RueFBM+g7nizpebEBZiyCi/D3hfX7dLXBO yogw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=IxRms8oq1KnpqAE9d17MGBR8i4plf+Lk5U8zFh4PNwg=; b=XUejF0MoGALMRXQgUXg6pfWHghkxi2YvIYTGfKisX5bgyooNpGTE+to1+5Hxu9YsLx ilGmwDSTvBDkF31K0QkSFI/D3rsCogNg5FsPytbsnvIukv7bMHQYSvkM7HSkaoReaHqN xhJH0S72zB9kPqSVf9fFlrTiLiPN57u+CplCrledq8kc5J/vcvOvsEvosj360kJci1aU z1DoMjJJGiW4ZR6I3hINqS8pqq8npjGn837AJFoXGK6AUn6QQXw735SJwT3kLm6WxWwN zGOfSQDkpflV7PHN4tGVFHqKcgPt8QDoIKKe/fEHnGMPDwxK3xDZpR4aV36pWcz4aOJP 6zig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si20716806jar.85.2021.06.21.19.40.22; Mon, 21 Jun 2021 19:40:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231487AbhFVClM (ORCPT + 99 others); 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: linux-kernel@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);