Date: Mon, 11 Feb 2019 22:09:27 +0000 (UTC) From: David Bright <dab@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r344024 - head/sys/cam/scsi Message-ID: <201902112209.x1BM9R4D049463@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dab Date: Mon Feb 11 22:09:26 2019 New Revision: 344024 URL: https://svnweb.freebsd.org/changeset/base/344024 Log: 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. Reviewed by: cem MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D19109 Modified: head/sys/cam/scsi/scsi_xpt.c Modified: head/sys/cam/scsi/scsi_xpt.c ============================================================================== --- head/sys/cam/scsi/scsi_xpt.c Mon Feb 11 21:31:26 2019 (r344023) +++ head/sys/cam/scsi/scsi_xpt.c Mon Feb 11 22:09:26 2019 (r344024) @@ -1385,6 +1385,12 @@ out: 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 || @@ -1397,9 +1403,6 @@ out: xpt_release_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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902112209.x1BM9R4D049463>