Re: [PATCH] mm/gup: add NULL check for unlocked parameter in fixup_user_fault()
From: Jason Gunthorpe
Date: Wed Aug 26 2026 - 10:16:53 EST
On Wed, Aug 26, 2026 at 02:29:43PM +0800, Liu Dalin wrote:
> While the current callers either pass a valid pointer or explicitly
> pass NULL (indicating they don't need the unlock notification), it is
> safer to add a defensive NULL check before dereferencing. This prevents
> a kernel crash if any caller passes NULL and handle_mm_fault() returns
> VM_FAULT_COMPLETED or VM_FAULT_RETRY.
>
> Fixes smatch warnings:
> - mm/gup.c:1597 fixup_user_fault() error: we previously assumed 'unlocked' could be null (see line 1573)
It would be better to remove the previous check:
if (unlocked)
fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
And update the kdoc if it is now true that the unlocked parameter
cannot be null
Jason