[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZFll93wsEUZIV/aI@casper.infradead.org>
Date: Mon, 8 May 2023 22:13:27 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Theodore Ts'o <tytso@....edu>
Cc: Tudor Ambarus <tudor.ambarus@...aro.org>, adilger.kernel@...ger.ca,
linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
joneslee@...gle.com, linux-mm@...ck.org
Subject: Re: [PATCH] ext4: remove superfluous check that pointer is not NULL
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 <tudor.ambarus@...aro.org>
>
> 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.
Powered by blists - more mailing lists