aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2025-07-07 20:05:10 +0000
committerWarner Losh <imp@FreeBSD.org>2025-07-07 23:17:00 +0000
commit5102c5f1134281aadea878a61cfe4967cab0eb9e (patch)
tree8f6c589ddf34ab1e0615d17c311930660cfda084
parent3b3591d3e1ac6423570201da0b23ab3d087816a9 (diff)
-rw-r--r--sys/cam/scsi/scsi_xpt.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c
index 2506a9fba799..1dd149b00a87 100644
--- a/sys/cam/scsi/scsi_xpt.c
+++ b/sys/cam/scsi/scsi_xpt.c
@@ -1915,6 +1915,15 @@ typedef struct {
int lunindex[0];
} scsi_scan_bus_info;
+static void
+free_scan_info(scsi_scan_bus_info *scan_info)
+{
+ KASSERT(scan_info->cpi != NULL,
+ ("scan_info (%p) missing its ccb_pathinq CCB\n", scan_info));
+ xpt_free_ccb((union ccb *)scan_info->cpi);
+ free(scan_info, M_CAMXPT);
+}
+
/*
* To start a scan, request_ccb is an XPT_SCAN_BUS ccb.
* As the scan progresses, scsi_scan_bus is used as the
@@ -2034,16 +2043,14 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
printf(
"scsi_scan_bus: xpt_create_path failed with status %#x, bus scan halted\n",
status);
- xpt_free_ccb((union ccb *)scan_info->cpi);
- free(scan_info, M_CAMXPT);
+ free_scan_info(scan_info);
request_ccb->ccb_h.status = status;
xpt_done(request_ccb);
break;
}
work_ccb = xpt_alloc_ccb_nowait();
if (work_ccb == NULL) {
- xpt_free_ccb((union ccb *)scan_info->cpi);
- free(scan_info, M_CAMXPT);
+ free_scan_info(scan_info);
xpt_free_path(path);
request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
xpt_done(request_ccb);
@@ -2205,12 +2212,11 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
if (done) {
mtx_unlock(mtx);
xpt_free_ccb(request_ccb);
- xpt_free_ccb((union ccb *)scan_info->cpi);
request_ccb = scan_info->request_ccb;
CAM_DEBUG(request_ccb->ccb_h.path,
CAM_DEBUG_TRACE,
("SCAN done for %p\n", scan_info));
- free(scan_info, M_CAMXPT);
+ free_scan_info(scan_info);
request_ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(request_ccb);
break;
@@ -2230,9 +2236,8 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
"scsi_scan_bus: xpt_create_path failed with status %#x, bus scan halted\n",
status);
xpt_free_ccb(request_ccb);
- xpt_free_ccb((union ccb *)scan_info->cpi);
request_ccb = scan_info->request_ccb;
- free(scan_info, M_CAMXPT);
+ free_scan_info(scan_info);
request_ccb->ccb_h.status = status;
xpt_done(request_ccb);
break;