s390/mm/gmap: Fix __gmap_fault() return code

Errors in fixup_user_fault() were masked and -EFAULT was returned for
any error, including out of memory.

Fix this by returning the correct error code. This means that in many
cases the error code will be propagated all the way to userspace.

Suggested-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Link: https://lore.kernel.org/r/20241022120601.167009-5-imbrenda@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
Claudio Imbrenda 2024-10-22 14:05:54 +02:00 committed by Heiko Carstens
parent 075fd7362c
commit 473aaf52b9

View File

@ -718,13 +718,12 @@ static int __gmap_fault(struct gmap *gmap, unsigned long gaddr, unsigned int fau
if (IS_ERR_VALUE(vmaddr))
return vmaddr;
if (fault_flags & FAULT_FLAG_RETRY_NOWAIT) {
if (fault_flags & FAULT_FLAG_RETRY_NOWAIT)
rc = fixup_user_fault_nowait(gmap->mm, vmaddr, fault_flags, &unlocked);
if (rc)
return rc;
} else if (fixup_user_fault(gmap->mm, vmaddr, fault_flags, &unlocked)) {
return -EFAULT;
}
else
rc = fixup_user_fault(gmap->mm, vmaddr, fault_flags, &unlocked);
if (rc)
return rc;
/*
* In the case that fixup_user_fault unlocked the mmap_lock during
* fault-in, redo __gmap_translate() to avoid racing with a