Re: [PATCH v3 1/2] mm, swap: distinguish a malformed swap entry from a dying device

Nhat Pham <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <CAKEwX=OJGV=f3hBOwE-jfxx8WaQmKRC8B26sjEgvTEShHjzb+A@mail.gmail.com>
On Tue, Aug 18, 2026 at 3:08 AM Breno Leitao <[email protected]> wrote:
>
> get_swap_device() returns NULL for two different things: an entry whose
> type names no swap device or whose offset is past the end of one, and a
> device that swapoff is taking away. The first never becomes valid, the
> second does, and callers cannot tell them apart.
>
> Return ERR_PTR(-EIO) for the two malformed cases and keep NULL for
> swapoff. copy_nonpresent_pte() already reports -EIO for an entry whose
> type names no device.
>
> Callers bail out on failure either way, so switch them to
> IS_ERR_OR_NULL(), and let the two paths that drop the reference skip an
> error pointer. No functional change.
>
> Reviewed-by: Barry Song <[email protected]>
> Acked-by: Kairui Song <[email protected]>
> Signed-off-by: Breno Leitao <[email protected]>

Reviewed-by: Nhat Pham <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.