Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4439389ioa; Wed, 27 Apr 2022 04:02:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5uR2+/45w5JwJ1/bX826fv3QY97uQrRcz2wvogO2eKjy7VwFIxTq/dsAtstOS5g5lDl1Q X-Received: by 2002:a65:6a07:0:b0:39d:8c35:426b with SMTP id m7-20020a656a07000000b0039d8c35426bmr23762150pgu.171.1651057370166; Wed, 27 Apr 2022 04:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651057370; cv=none; d=google.com; s=arc-20160816; b=kdBlQ2oJRcvMB+PlI01dcMs+uwywoKtodWvbvLxUNp3E+gXSZHaIfIm2wpKGVKTxD/ Cds4J9/cbZwO9Oj5yvzwIrfMg9s5jznZsvHKWZafF85jW3jWzmTi66s9oCB1ch/NwkG+ THfsxOsHnTPTrmkve5S5cUfoCbIhAg89nSzWtpGrVF62lW96x6Hp9ez5QJqjGbI8Qrml bqU8mG0JrrPjhy3T43Jr3kt0LKCamcMF0dzgSvELh0WH1lV+wuGd8uUafPTDmKYvTVma JZTvCasm1meuHnXcRoOgIEO5CN3yC6b6h9A38vLfZuNtmJUpotAbb2LltKt/AuJ6gd29 cM9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=YKRyRoRn1J7AVZnClLp4tkIFjiP9PurfbUvI7JSKVyc=; b=zFN6fc1sPtqSPo1YVCF5MD+CH0yFJjKqp3okggoSFPNe7M6IP0uK/RP6YcV3H80jbM 9Yun9Kix+Oq0aoCWmv+3ocDEZ8i92XEkLoCz9Vfwqhcf0aMkHA9rnezRPeQm9eUPfn1d 6CA6bTqD2q72KZYjU5dZ/MkfdmF7B91pQ1+LUSJ2ViRU4sIJlTUwCethJc+4q5OWoa4g /FxZ74+qoBaegKbLRlvW3m4p2c8KKrG9mvrihb3eVbcGYC7hCV9oKCizXFq/AEobftLA SwXgmkkzZ/FpGoUXSTpZqqGlPhCwdl1YkhyVfNdK4K7y1oRYrLRXrOyjb+wps3JfI3sZ VEgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=AXxJUn48; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u13-20020a170902714d00b00153b2d165d5si1133677plm.477.2022.04.27.04.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:02:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=AXxJUn48; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 335BF4630C2; Wed, 27 Apr 2022 03:11:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355216AbiDZVJ4 (ORCPT + 99 others); Tue, 26 Apr 2022 17:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243506AbiDZVJy (ORCPT ); Tue, 26 Apr 2022 17:09:54 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF2616D4D6 for ; Tue, 26 Apr 2022 14:06:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 3E1C9CE2192 for ; Tue, 26 Apr 2022 21:06:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 436CFC385A4; Tue, 26 Apr 2022 21:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1651007202; bh=d4vNieU9C1R0ukFjOzDog7Jl8A2oEUBzKVDoPNTk3nM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AXxJUn48WsZtYjaYH0DI8pHLDlx7PBvGooyg/6vOF38p1y+7q1zK+T7jRi3mLFiGa KdEp1mW7w514E4UPK26+Bm+gp7OHsUr65lEFgt+a0ENPg6Gzks5Iqqzrp3ueHC14rF LEiUkPPhvZzEkEGXIGeVTbve4XAKCs7oOKmxqqjg= Date: Tue, 26 Apr 2022 14:06:41 -0700 From: Andrew Morton To: Matthew Wilcox Cc: Wan Jiabing , Vlastimil Babka , David Howells , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Julia Lawall Subject: Re: [PATCH] mm/filemap: Fix NULL pointer dereference in pagecache_get_page Message-Id: <20220426140641.cc78a429e1fa32ed0e15520b@linux-foundation.org> In-Reply-To: References: <20220426082549.590899-1-wanjiabing@vivo.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Apr 2022 13:08:08 +0100 Matthew Wilcox wrote: > On Tue, Apr 26, 2022 at 04:25:48PM +0800, Wan Jiabing wrote: > > Fix following coccicheck error: > > mm/folio-compat.c:128:17-21: ERROR: folio is NULL but dereferenced. > > folio = __filemap_get_folio(mapping, index, fgp_flags, gfp); > > - if ((fgp_flags & FGP_HEAD) || !folio || xa_is_value(folio)) > > + if (!folio) > > + return NULL; > > + if ((fgp_flags & FGP_HEAD) || xa_is_value(folio)) > > return &folio->page; > > That doesn't dereference the folio. Coccicheck is wrong. Doing return &(0->page); is a rather obscure way of doing `return NULL;'. I agree the patch doesn't fix anything, but it results in saner-looking code?