From nobody Mon Jul 7 23:18:23 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bbgCN27MZz61VDy; Mon, 07 Jul 2025 23:18:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bbgCM2qtJz41KR; Mon, 07 Jul 2025 23:18:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751930303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yPzzeUzw4qFF0qMDDwFBAm1cmxb4gVTfBYJE347W7cU=; b=CIuiBVlLooFHSkDwwfZ8IhSGm2Djmpjf/RJjrUCEiNuUV1DcU9hcV/Ej8Nx1//HDCZIbhE ZHsKAKDQPbjZyfXhZ9+SsRUiZQUqpAK7f2+KjQKE14Ff6VD4yy7asxbBM7OEVFu3ErirkH GK4aJlGpsXlr5hBdQoCBoJo8IPLXvLQWw430GxRkRXWRK1PUtssrLMShZe3ogpuIBFy09U 31xmehVyTNUosxAL7Gc6KhP/al5BVddjVOXDGPPvmd9fvfIDUaCJUsJB6TiVcKwxzKXdek EAyaiWgHUbxN79DLHHURD+bA8LvdwJORxDa0WvafhIb3hCoo6/mX5hg6dlT2QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751930303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yPzzeUzw4qFF0qMDDwFBAm1cmxb4gVTfBYJE347W7cU=; b=MY8X4tmCoOStEyQy917hMecWBGHbh7z7SEYJGGfBY806peDOMXPiRLgOIHOZAuhFulWf85 tg5+NVXQMSSaUt18OYgWtw4XtF0Az4XA8uowL3JBwuR8KJt9z22cmWFcvcGSGNjgTvHcim RwhEdlnplEKBlsTxBtjVfDLwRQatQrW92+UExeqKDnlG454zsMTV1CpNZFagYrEaKdD7uB eTIcIxcuJXxt/VjTVMwRZ8rvyT98B4oSYiGZZITzn3B/df6AGroVExYaaBGqy+YkITMDlP BXUL50D2kr90ngOtaBVZaNR/m5JFcVAUlpICg+6Zf1sdABLxb+PGhNxqGKxarA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751930303; a=rsa-sha256; cv=none; b=iepS4Z8xHlnKdIlG5GMnRmykyrn832NC5wav85jZv/1vvtb+nqN2BwSUF35kvMrKsASnqN G+xFoHKKKWniMUw7Mg7dVQXN6C/Wk6thP2JUINz3VdBtc2xj4EC/UGchnJ4p60iOmiDISz gOPuL8GawzXzdlnWJdyDOVYjHQvt6RZHLXuyvuYr3Gh2COgK8jg4284qsx6KGuyLSwt5w3 RauOUYhRM6DHdxaNjpSwgU2N/ZlVv60ISmOO7c3Ky0P549a8HpVK3oWzwtVsI6nowGO+Qy UYrSjIRrZiI4f8g8Q1UHkQafMErAG2hZZwTWQ0tbiMcE1fRVvr//SX9sLPMLdA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bbgCM1kx2z19sf; Mon, 07 Jul 2025 23:18:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 567NINrp045760; Mon, 7 Jul 2025 23:18:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 567NINWt045757; Mon, 7 Jul 2025 23:18:23 GMT (envelope-from git) Date: Mon, 7 Jul 2025 23:18:23 GMT Message-Id: <202507072318.567NINWt045757@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 5102c5f11342 - main - cam: Create free_scan_info helper function List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5102c5f1134281aadea878a61cfe4967cab0eb9e Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5102c5f1134281aadea878a61cfe4967cab0eb9e commit 5102c5f1134281aadea878a61cfe4967cab0eb9e Author: Warner Losh AuthorDate: 2025-07-07 20:05:10 +0000 Commit: Warner Losh CommitDate: 2025-07-07 23:17:00 +0000 cam: Create free_scan_info helper function We free the scsi bug scan info in 4 places. 1 was wrong until I fixed a bug there in a recent commit. Introduce a helper function that will free the cpi always (it must always be valid since we set it right after allocation). Sponsored by: Netflix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D51170 --- sys/cam/scsi/scsi_xpt.c | 21 +++++++++++++-------- 1 file 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;