--- a/sys/dev/disk/mpt/mpt_raid.c +++ b/sys/dev/disk/mpt/mpt_raid.c @@ -283,7 +283,12 @@ error = mpt_spawn_raid_thread(mpt); if (error != 0) { mpt_prt(mpt, "Unable to spawn RAID thread!\n"); - goto cleanup; + /* + * Nothing to unwind yet: MPT_LOCK is not held, no CCB was + * allocated, no handler was registered. Falling through + * to cleanup would MPT_UNLOCK an unheld lock and panic. + */ + return (error); } csa = &xpt_alloc_ccb()->csa; @@ -312,6 +312,7 @@ mpt_raid_sysctl_attach(mpt); return (0); cleanup: + xpt_free_ccb(&csa->ccb_h); /* only reached after csa was allocated */ MPT_UNLOCK(mpt); mpt_raid_detach(mpt); return (error);