diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -1494,8 +1494,12 @@ bailout: if (need_copy != 0) { if (error != EFAULT) { + int error1; + cam_periph_unlock(periph); - copyout(params, list->params, list->param_len); + error1 = copyout(params, list->params, list->param_len); + if (error == 0) + error = error1; cam_periph_lock(periph); } free(params, M_SCSISA);