Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4432961ioa; Wed, 27 Apr 2022 03:53:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyor84bw1AHi+ohRuEqegAVAHobnrhUoBV6o0WE0XiexzvT7E9I146UAYgGQjqZ7I+F7j1V X-Received: by 2002:a17:902:bc8b:b0:158:ac00:cca0 with SMTP id bb11-20020a170902bc8b00b00158ac00cca0mr28180690plb.102.1651056796172; Wed, 27 Apr 2022 03:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056796; cv=none; d=google.com; s=arc-20160816; b=asYhiONcUXG3f6VQHr8418llKTEglq5evc3wjDFgDEWBwLNo4vk+jtAVrAozADEUnu eDJaNcyRanABHh9lEsoj9w7as9JwxhIdYmUfiv4f2yCImPBp4wzcce0sZ5/xchwMaFgp Iuxady0Hk+PHBZsKxr1Xp1EistdmI8MP+kjdcTREQFaZZmdRe4/DTV+8ykQyk6z89TMe teQ7hr9FT2xQL07Xv7JHq521fS8THpPoTvQ2Yjue4l1GfIhmjcbXDxOf8UGjgZhJjfwR Hg1tOgIgMO8NnmD989UU0jlSm10A3n4L4Vk7HctMjjwcgl/Z0ylgaLf2pi5i7tbzkPNp mdBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=h0WM/OGYr1vmddkP3aThoTDj/4ylnz0kGYAAy3EuZGE=; b=CA4XTiAakHoDQEVX17ZJ9GcetNAJDHv8V79WVqt+WlWnqQj2oZLXqQyz7V7L4k9f7N xNRRmcGMbKfjK3sMucFmrvf2uqp/1ltKZ4RQnNKRoIqfIHsrCQinV1bZn+PjR86CF/Bp fWykF/L8eyVoK53qjz2MYE45qC1YI9Bktm00o2JPUz/Hdv5BOM8Ur6jfPhqZR374uVEV WWuAlwg6Bn65vDVVZTIThuBT926JIPEVwKiYa2bZD8Wt4RBkB2rd6UeDwX9yvUimCcJy 0DLayTwYhDpUS0qiNRMODNVchUBAQ8NBiTPUL82n1SvNcF2XpbKv+aZX9gtYbe6Ooxji zcnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kyguCSba; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e6-20020a170902ef4600b00155c6577751si1294980plx.33.2022.04.27.03.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:53:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kyguCSba; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 44B32771CB; Wed, 27 Apr 2022 02:58:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355334AbiDZVU6 (ORCPT + 99 others); Tue, 26 Apr 2022 17:20:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355329AbiDZVU5 (ORCPT ); Tue, 26 Apr 2022 17:20:57 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17A2C865B for ; Tue, 26 Apr 2022 14:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=h0WM/OGYr1vmddkP3aThoTDj/4ylnz0kGYAAy3EuZGE=; b=kyguCSba/X6mQN+uANNGnuh6F/ AF0v4xllc6XsTsqebSYH2ppi/bm/62UZRT13hR9l9rtDgtTieEpaXnocYc/Q7Qv/W7WklIsbeiE0i 4QinJ/i97z7pcmWJkvkHNutWrYDjeyk3/FfmiicUPHaCdT3PjHE5Z2gwSLTNO3vSrGXTwibBwYuTF V4Ncqn0p2LHcsNVDsGEG5o4VTM9R2lqV4xtixba06P7K7mPYZ/vNYf1mZJfnAzpyrXa3txdP8ZomX jL0lgbQ9BMmLmHEzdAaLD1Pk1l9F69L3WKKepkohrtPADyPob5E6r0BOoaWDqpzTQSk0DpWHDIh4n ucWqiC9A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1njSYz-00A1ET-5j; Tue, 26 Apr 2022 21:17:37 +0000 Date: Tue, 26 Apr 2022 22:17:37 +0100 From: Matthew Wilcox To: Andrew Morton 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: References: <20220426082549.590899-1-wanjiabing@vivo.com> <20220426140641.cc78a429e1fa32ed0e15520b@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220426140641.cc78a429e1fa32ed0e15520b@linux-foundation.org> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no 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, Apr 26, 2022 at 02:06:41PM -0700, Andrew Morton wrote: > 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? I suppose that's in the eye of the beholder? The original code makes more sense to me. Besides, it's in the folio-compat file; nobody should be looking at that except to figure out "What function should I be transitioning to?"