HomeFreeBSD

cam: In scsi_scan_bus, fix an error case

Description

cam: In scsi_scan_bus, fix an error case

If we can't allocate the new path when loopoing over the target range,
then we have to free the scan_info->cpi CCB, not the work_ccb. This was
accidentally correct for the first iteration (because work_ccb ==
scan_info->cpi), but incorrect after that since we'll be freeing the CCB
for XPT_SCAN_LUN for the prior LUN we kicked off. Reorder the free so we
free it before we free scan_info so the pointer is still valid.

I do not have a test case for this since it requires that we fail in the
second or later iteration of the loop due to low memory, and only
fuzzing would catch that.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D51169

Details

Provenance
impAuthored on Jul 7 2025, 8:05 PM
Reviewer
jhb
Differential Revision
D51169: cam: In scsi_scan_bus, fix an error case
Parents
rGa2056e854957: cam/mmc: Use xpt_path_inq instead of hand-rollded equivalent
Branches
Unknown
Tags
Unknown