Skip to contentSkip to conversation

s390/diag324: Preserve -EBUSY return code

PATCH Applied Sumanth Korikkar 3 participants 3 messages Aug 11 – Aug 24 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/diag324: Preserve -EBUSY return code

When diag324 reports -EBUSY, the error code is
overwritten by the result of copy_to_user() and put_user(). As a result, the ioctl may incorrectly return success instead of -EBUSY.

Preserve the original diag324 return code and only return -EFAULT when copying data to userspace fails.

Fixes 90e6f191e1ee ("s390/diag324: Retrieve power readings via diag 0x324")
---
 arch/s390/kernel/diag/diag324.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/kernel/diag/diag324.c +1 -2
index fe325c2a2d0d..3eec0cc8fb9e 100644
@@ -182,8 +182,7 @@ long diag324_pibbuf(unsigned long arg)
 		goto out;
 	rc = copy_to_user((void __user *)address, data->pib, data->pib->len);
 	rc |= put_user(data->sequence, &udata->sequence);
-	if (rc)
-		rc = -EFAULT;
+	rc = rc ? -EFAULT : data->rc;
 out:
 	mutex_unlock(&pibmutex);
 	return rc;
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Sumanth Korikkar

When diag324 reports -EBUSY, the error code is
overwritten by the result of copy_to_user() and put_user(). As a result, the ioctl may incorrectly return success instead of -EBUSY.

Quoted 8 lines

Preserve the original diag324 return code and only return -EFAULT when copying data to userspace fails.

Fixes 90e6f191e1ee ("s390/diag324: Retrieve power readings via diag 0x324")
---
 arch/s390/kernel/diag/diag324.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
maintainer Applied
#2 lore raw
In reply to Sumanth Korikkar
Quoted 4 lines · Sumanth Korikkar

When diag324 reports -EBUSY, the error code is
overwritten by the result of copy_to_user() and put_user(). As a result, the ioctl may incorrectly return success instead of -EBUSY.

Quoted 8 lines

Preserve the original diag324 return code and only return -EFAULT when copying data to userspace fails.

Fixes 90e6f191e1ee ("s390/diag324: Retrieve power readings via diag 0x324")
---
 arch/s390/kernel/diag/diag324.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Applied, thank you!