git: 74e713804fa4 - main - iscsi: Check for copyout errors in iscsi_ioctl_daemon_receive()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 26 Dec 2023 02:04:34 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=74e713804fa4767991c5f20e6b85da4235107122

commit 74e713804fa4767991c5f20e6b85da4235107122
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-26 01:43:31 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-12-26 02:04:01 +0000

    iscsi: Check for copyout errors in iscsi_ioctl_daemon_receive()
    
    Reviewed by:    jhb
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D43148
---
 sys/dev/iscsi/iscsi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c
index 57292c6ff309..4ed8f086ccde 100644
--- a/sys/dev/iscsi/iscsi.c
+++ b/sys/dev/iscsi/iscsi.c
@@ -1896,17 +1896,17 @@ iscsi_ioctl_daemon_receive(struct iscsi_softc *sc,
 		return (EMSGSIZE);
 	}
 
-	copyout(ip->ip_bhs, idr->idr_bhs, sizeof(*ip->ip_bhs));
-	if (ip->ip_data_len > 0) {
+	error = copyout(ip->ip_bhs, idr->idr_bhs, sizeof(*ip->ip_bhs));
+	if (error == 0 && ip->ip_data_len > 0) {
 		data = malloc(ip->ip_data_len, M_ISCSI, M_WAITOK);
 		icl_pdu_get_data(ip, 0, data, ip->ip_data_len);
-		copyout(data, idr->idr_data_segment, ip->ip_data_len);
+		error = copyout(data, idr->idr_data_segment, ip->ip_data_len);
 		free(data, M_ISCSI);
 	}
 
 	icl_pdu_free(ip);
 
-	return (0);
+	return (error);
 }
 #endif /* ICL_KERNEL_PROXY */