Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4465547pxj; Tue, 22 Jun 2021 00:26:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA3HjCLVmTt8xpL049gbqBEvndvFxAaLoTTqCBybZzaeBuj0JenNmWqVHN1nIuiDjOsyd2 X-Received: by 2002:a05:6402:50ce:: with SMTP id h14mr3064547edb.219.1624346809531; Tue, 22 Jun 2021 00:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624346809; cv=none; d=google.com; s=arc-20160816; b=DcjMDDIcGAnQHOoJ/zNLmPNSi+1iGY5dmCWkBz2svTRWpnmX6zrBN62MCxhO8q/G9x DKGuKUKk6/IfcLnE2rTGf4VYIF8qopN+3mkeLV0qh2bfIs5Trmz7hVLsLZa8z/PNcvDz rIvtsEXw7Bo3fcPZlFD432mkXvSW7SojhOLvCHZxuIgffdfj7LMcDIzB2KBIs25mvBN4 npJr3Tuy0bJVKp0eVK/XEE0gRiWj1XWfN8V5aU+PmVK0LU1mrI2lPQ6GDR6wHtJFEgvB 9fCNUsI4omD13k77ufBGrnzZHG+FH71+8fFqxAK3aeLvL/eUvVHoLkiGoaSO5P/kuKm5 YhEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=nZSVZ1ZETEgvA6vanHomHgndPYgE6cfRKbQi+iXbCIc=; b=ORklbFi09KKYzafjYnIDV2wPo1aTZDRKJ2s3ECdzizMp3ppx/DW3KvzmOuOy+ao6m9 +H7ywLaHIJLjgS+bW4CZ/yioLGH98M43RPRJs158pYtz9jWeQUE2mBRwcRnlNMcFoFr3 fz/Bdozi27n1oOC+NzTPEMjKSW8o4MdXaQi+9zmsYHe+EaocWEg3ZSuybvgsx1KMcOl5 JinfjGysoCkKw9Ao3FGu6sK3am1b/H5D7Rtu8pB8rQ9IO0/39JdMZmKMI9Tovp2qdrcQ 0U1QlBVNp/1e0U9r24upYcTqel8D4lFmZnvjNtJGvpzz2c8x1f9TeQEDicLRCXSOt4c2 ZRGw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y18si1528217edc.168.2021.06.22.00.26.27; Tue, 22 Jun 2021 00:26:49 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbhFVH0d convert rfc822-to-8bit (ORCPT + 99 others); Tue, 22 Jun 2021 03:26:33 -0400 Received: from lithops.sigma-star.at ([195.201.40.130]:53252 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbhFVH0c (ORCPT ); Tue, 22 Jun 2021 03:26:32 -0400 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id B1CAA606BA3F; Tue, 22 Jun 2021 09:24:15 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id URpEKndo4VDj; Tue, 22 Jun 2021 09:24:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 5D6A261BC7C5; Tue, 22 Jun 2021 09:24:15 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Tx88bZgyxVTX; Tue, 22 Jun 2021 09:24:15 +0200 (CEST) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id 320C961BC7B2; Tue, 22 Jun 2021 09:24:15 +0200 (CEST) Date: Tue, 22 Jun 2021 09:24:15 +0200 (CEST) From: Richard Weinberger To: chengzhihao1 Cc: Colin Ian King , Dan Carpenter , linux-mtd , kernel-janitors , linux-kernel Message-ID: <1471996381.142265.1624346654994.JavaMail.zimbra@nod.at> In-Reply-To: References: <20210621152249.20901-1-colin.king@canonical.com> Subject: Re: [PATCH] ubifs: Remove a redundant null check on pointer lp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [195.201.40.130] X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF78 (Linux)/8.8.12_GA_3809) Thread-Topic: ubifs: Remove a redundant null check on pointer lp Thread-Index: ZwnP86hcvaby+ZSpOm73bGFflCebzw== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Ursprüngliche Mail ----- > 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(). Good catch! :-) >> - 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); I'll drop Dan's patch from -next. Do you want to send a followup patch which removes the in vain check? Thanks, //richard