git: 9fcacefa3812 - stable/14 - sa: Check for errors from copyout()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 04 Jan 2024 13:48:07 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=9fcacefa381276db6f19ab21992aff7237f8e6c1

commit 9fcacefa381276db6f19ab21992aff7237f8e6c1
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-27 21:28:28 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-04 13:42:26 +0000

    sa: Check for errors from copyout()
    
    This is in preparation for annotating copyin() and related functions
    with __result_use_check.
    
    Reviewed by:    ken
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D43203
    
    (cherry picked from commit 4d3c234d8eb32f903d630b371208a0a931d3d5fe)
---
 sys/cam/scsi/scsi_sa.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c
index 78b22ba7eba1..07b917daa0c0 100644
--- a/sys/cam/scsi/scsi_sa.c
+++ b/sys/cam/scsi/scsi_sa.c
@@ -1495,8 +1495,12 @@ saparamsetlist(struct cam_periph *periph, struct mtsetlist *list,
 bailout:
 	if (need_copy != 0) {
 		if (error != EFAULT) {
+			int error1;
+
 			cam_periph_unlock(periph);
-			copyout(params, list->params, list->param_len);
+			error1 = copyout(params, list->params, list->param_len);
+			if (error == 0)
+				error = error1;
 			cam_periph_lock(periph);
 		}
 		free(params, M_SCSISA);