From f3b4f561ab8c6b1ea758ca979435e73a8f5808a0 Mon Sep 17 00:00:00 2001 From: dab Date: Wed, 20 Feb 2019 22:49:09 +0000 Subject: [PATCH] MFC r344024: CID 1009492: Logically dead code in sys/cam/scsi/scsi_xpt.c In `probedone()`, for the `PROBE_REPORT_LUNS` case, all paths that fall to the bottom of the case set `lp` to `NULL`, so the test for a non-NULL value of `lp` and call to `free()` if true is dead code as the test can never be true. Fix by eliminating the whole if statement. To guard against a possible future change that accidentally violates this assumption, use a `KASSERT()` to catch if `lp` is non-NULL. Sponsored by: Dell EMC Isilon git-svn-id: svn://svn.freebsd.org/base/stable/10@344394 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/cam/scsi/scsi_xpt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index bb60591c7..9b65109eb 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -1351,6 +1351,12 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) probe_purge_old(path, lp, softc->flags); lp = NULL; } + /* The processing above should either exit via a `goto + * out` or leave the `lp` variable `NULL` and (if + * applicable) `free()` the storage to which it had + * pointed. Assert here that is the case. + */ + KASSERT(lp == NULL, ("%s: lp is not NULL", __func__)); inq_buf = &path->device->inq_data; if (path->device->flags & CAM_DEV_INQUIRY_DATA_VALID && (SID_QUAL(inq_buf) == SID_QUAL_LU_CONNECTED || @@ -1364,9 +1370,6 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) xpt_schedule(periph, priority); goto out; } - if (lp) { - free(lp, M_CAMXPT); - } PROBE_SET_ACTION(softc, PROBE_INVALID); xpt_release_ccb(done_ccb); break; -- 2.45.0