git: 5f5da36a3a05 - stable/13 - iscsi: Check for copyout errors in iscsi_ioctl_daemon_receive()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 02 Jan 2024 01:13:15 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=5f5da36a3a05876dfaeee51810913e5558357662

commit 5f5da36a3a05876dfaeee51810913e5558357662
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-26 01:43:31 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-02 01:12:45 +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
    
    (cherry picked from commit 74e713804fa4767991c5f20e6b85da4235107122)
---
 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 ec5adf417867..51cfe7aca71d 100644
--- a/sys/dev/iscsi/iscsi.c
+++ b/sys/dev/iscsi/iscsi.c
@@ -1863,17 +1863,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 */