git: 904cd456f0f9 - main - targ: Handle errors from suword()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 04 Jan 2024 13:40:23 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=904cd456f0f95c10fdb4c99a0118f30d23242dec
commit 904cd456f0f95c10fdb4c99a0118f30d23242dec
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-04 13:34:31 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-04 13:39:53 +0000
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 f1c01cab8638..034b528b415c 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);