From 904cd456f0f95c10fdb4c99a0118f30d23242dec Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 4 Jan 2024 08:34:31 -0500 Subject: [PATCH] targ: Handle errors from suword() In targstart() we are already handling an error and have no go way to signal the failure to upper layers, so ignore the return value of suword() there. This is in preparation for annotating copyin() and related functions with __result_use_check. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43202 --- sys/cam/scsi/scsi_target.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index f1c01cab863..034b528b415 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -634,8 +634,8 @@ targstart(struct cam_periph *periph, union ccb *start_ccb) xpt_print(periph->path, "targsendccb failed, err %d\n", error); xpt_release_ccb(start_ccb); - suword(&descr->user_ccb->ccb_h.status, - CAM_REQ_CMP_ERR); + (void)suword(&descr->user_ccb->ccb_h.status, + CAM_REQ_CMP_ERR); TAILQ_INSERT_TAIL(&softc->abort_queue, descr, tqe); notify_user(softc); } @@ -867,7 +867,10 @@ targread(struct cdev *dev, struct uio *uio, int ioflag) CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("targread aborted descr %p (%p)\n", user_descr, user_ccb)); - suword(&user_ccb->ccb_h.status, CAM_REQ_ABORTED); + if (suword(&user_ccb->ccb_h.status, CAM_REQ_ABORTED) != 0) { + error = EFAULT; + goto read_fail; + } cam_periph_unlock(softc->periph); error = uiomove((caddr_t)&user_ccb, sizeof(user_ccb), uio); cam_periph_lock(softc->periph);