Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4885951rwr; Mon, 8 May 2023 14:19:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5iGLPU49a/bYT/igQVEOPzBE1+KaE0Yzjsjce31SNpZCSjdkZ5UKdXYvD0EyB0NeB+nm6C X-Received: by 2002:a05:6a20:8f25:b0:ff:7031:541a with SMTP id b37-20020a056a208f2500b000ff7031541amr11887354pzk.44.1683580773757; Mon, 08 May 2023 14:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683580773; cv=none; d=google.com; s=arc-20160816; b=W6L6aB1ieNaHbWJZTxTwg+RnjoykSrYZ/W2y6ml+BnQg8aqDHKL6HWXpamu9ZMdAX6 AntRxZDtb2e/K36AhWBIXpo50ZkdH4Y/O8XAbwLjE4xQoOgPEKiPoPAds46XiVTTwYNM 9P9NtPyZwHzzBP0Rgfvp4c4fKwIT158w68BUn529qccd5gFYxCm9b3I17Lg5tIJoA/Mm rHVJvcPsdohsaGuGmLHRqjH6qk4wymqAM6ReNZ0Eg9JPSUMGHPN9Ag/grF1cO97SAOfl mOA8tJU/kcCQbBfGSNK1+/afG7EqV7QS8IhDC8uvQ05p+IkMrkBN33K7aplW/CYI5WX0 EFsQ== 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=XOfR5eYqFEKI2MRwh9rMh2Y6eXpYj1Cs8OGL6W+hOOw=; b=ydn58frgbN+HaTOI2RnkApaLPXqC2lGKpr8dfm3RWqRfqfW0WiMyE0v2Kc0fWgeigR P12p1mvcCOagcpef8Yc0l0Hq36wGdjI6AypogfOgDYri0NSfO+h3pBiMGbBpyOTuTutE iIF+z7/PvHZzkW/4nku6mg+tFHZ3kdpUVz3N3WDGMGKxrmcrNjrMDksHwqGsUkJVuCFt Bk75vUzzRgi01947s7St3VkyGS+jtPN47YDGztZlI3j7Ui/AD6U67kFs1s4o3W8g6Lvu qSNyDfd2zVj6AETTDvH31cH4SmJ6TixjXM5bKr2jq86e+sAlm38ROK1LiDiAIpep00rJ 5AOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="Bm/xNlf3"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r21-20020a638f55000000b00520dfb861fbsi9218530pgn.416.2023.05.08.14.18.56; Mon, 08 May 2023 14:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="Bm/xNlf3"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbjEHVNg (ORCPT + 99 others); Mon, 8 May 2023 17:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjEHVNf (ORCPT ); Mon, 8 May 2023 17:13:35 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DE6B2D6D; Mon, 8 May 2023 14:13:33 -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=XOfR5eYqFEKI2MRwh9rMh2Y6eXpYj1Cs8OGL6W+hOOw=; b=Bm/xNlf3ZvZys8QuPJvX+zIHtq nF7j97jCosW8FystIsyTQ2INw9EuyYHCOMjd0w0y4cHC1w4p2Q3eld5ffdWccgKcxN25CqvmXcyX3 GXBRoOWKV86rvccyT20Y5M6fzHNguYjaRRogHBoWLr+LYfy7LIMoVtZJS4/WNjFvYM0hEurjjH6PK nD0FQ3QV0HxQZFkq2DxuuAKw2xcxd1+wohoCZQAwpbkRjjDc3nURzC5YjHSF31vV1/2g9Fr4+UdbK zKkg9wTCiPdjauQBSjjV07j+E7LFLkFeqGdXcxq3tm0G350ZAg+UA8e6jm0VrDbAhZAjiS8uyiH7S B6LBVoqA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pw8Ah-00EVH7-AR; Mon, 08 May 2023 21:13:27 +0000 Date: Mon, 8 May 2023 22:13:27 +0100 From: Matthew Wilcox To: Theodore Ts'o Cc: Tudor Ambarus , adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, joneslee@google.com, linux-mm@kvack.org Subject: Re: [PATCH] ext4: remove superfluous check that pointer is not NULL Message-ID: References: <20230508151337.79304-1-tudor.ambarus@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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-ext4@vger.kernel.org On Mon, May 08, 2023 at 12:14:54PM -0400, Theodore Ts'o wrote: > On Mon, May 08, 2023 at 03:13:37PM +0000, Tudor Ambarus wrote: > > If @buffer is NULL, no operation is performed for kvfree(buffer), > > remove superfluous check. > > > > Signed-off-by: Tudor Ambarus > > I was looking at this just a few weeks ago, and I couldn't find any > actual *documentation* that it was safe to call vfree(NIILL) or > kvfree(NULL). The problem is there are a lot of architecture-specific > functions, and unlike with kfree() there is no top-level "if (ptr == > NULL) return;" in the top-level vfree() and kvfree(). There doesn't need to be in kvfree(). is_vmalloc_addr() returns 'false' for NULL, so it calls kfree(), which as you note has an explicit check for ZERO_OR_NULL_PTR(). is_vmalloc_addr() also returns false for the ZERO pointer, fwiw. I agree that this should be explicitly documented as allowed, since it's not reasonable to expect users to dig through these functions to verify that such a change is safe.