From 473aaf52b937e2401c7ad161a6197bf88e920a9a Mon Sep 17 00:00:00 2001 From: Claudio Imbrenda Date: Tue, 22 Oct 2024 14:05:54 +0200 Subject: [PATCH] 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 Signed-off-by: Claudio Imbrenda Reviewed-by: Heiko Carstens Acked-by: Alexander Gordeev Link: https://lore.kernel.org/r/20241022120601.167009-5-imbrenda@linux.ibm.com Signed-off-by: Heiko Carstens --- arch/s390/mm/gmap.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index f51ad948ba53c..a8746f71c679a 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -718,13 +718,12 @@ retry: 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 -- 2.47.3