Re: [PATCH 2/3] mm, swap: distinguish a malformed swap entry from a dying device
From: Breno Leitao
Date: Wed Aug 12 2026 - 07:05:53 EST
Hello David,
On Tue, Aug 11, 2026 at 05:36:31PM +0200, David Hildenbrand (Arm) wrote:
> On 8/10/26 18:26, Breno Leitao wrote:
> > + return ERR_PTR(-EINVAL);
> > }
>
> Is -EINVAL really the logical right return value? Running into bad swap entries
> sounds more serious to me than "-EINVAL" :)
Good point, maybe we need a strong drug here, what about -EIO?
I picked -EINVAL because it is what the swap code already returns for
this exact condition.
* Returns -EINVAL if the swap entry is invalid, which might
* occur if a page table entry has got corrupted.
*/
int swap_dup_entry_direct(swp_entry_t entry)
{
si = swap_entry_to_info(entry);
if (WARN_ON_ONCE(!si)) {
pr_err("%s%08lx\n", Bad_file, entry.val);
return -EINVAL;
But, I do agree -EINVAL is too soft given the situation we are in.
I will return -EIO in the next version, if I don't hear any concern.