[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wiqaENZFBiAihFxdLr2E+kSM4P64M3uPzwT4-K9NiVSmw@mail.gmail.com>
Date: Mon, 12 Feb 2024 14:08:20 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Dan Williams <dan.j.williams@...el.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, Arnd Bergmann <arnd@...db.de>,
Dave Chinner <david@...morbit.com>, linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>, Vishal Verma <vishal.l.verma@...el.com>,
Dave Jiang <dave.jiang@...el.com>, Matthew Wilcox <willy@...radead.org>,
Russell King <linux@...linux.org.uk>, linux-arch@...r.kernel.org,
linux-cxl@...r.kernel.org, linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-xfs@...r.kernel.org, dm-devel@...ts.linux.dev, nvdimm@...ts.linux.dev,
linux-s390@...r.kernel.org, Alasdair Kergon <agk@...hat.com>,
Mike Snitzer <snitzer@...nel.org>, Mikulas Patocka <mpatocka@...hat.com>
Subject: Re: [PATCH v5 5/8] virtio: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal
On Mon, 12 Feb 2024 at 14:04, Dan Williams <dan.j.williams@...el.com> wrote:
>
> This works because the internals of virtio_fs_cleanup_dax(), "kill_dax()
> and put_dax()", know how to handle a NULL @dax_dev. It is still early
> days with the "cleanup" helpers, but I wonder if anyone else cares that
> the DEFINE_FREE() above does not check for NULL?
Well, the main reason for DEFINE_FREE() to check for NULL is not
correctness, but code generation. See the comment about kfree() in
<linux/cleanup.h>:
* NOTE: the DEFINE_FREE()'s @free expression includes a NULL test even though
* kfree() is fine to be called with a NULL value. This is on purpose. This way
* the compiler sees the end of our alloc_obj() function as [...]
with the full explanation there.
Now, whether the code wants to actually use the cleanup() helpers for
a single use-case is debatable.
But yes, if it does, I suspect it should use !IS_ERR_OR_NULL(ptr).
Linus
Powered by blists - more mailing lists