diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index cba7f11ce..eda4dfd6a 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -2676,12 +2676,17 @@ out: void scst_cm_update_dev(struct scst_device *dev) { + unsigned int lun; int rc, res; TRACE_ENTRY(); TRACE_MGMT_DBG("copy manager: updating device %s", dev->virt_name); + if (!scst_auto_cm_assignment || + !dev->handler->auto_cm_assignment_possible) + goto out; + res = scst_suspend_activity(SCST_SUSPEND_TIMEOUT_UNLIMITED); WARN_ON_ONCE(res); @@ -2693,7 +2698,11 @@ void scst_cm_update_dev(struct scst_device *dev) scst_block_dev(dev); spin_unlock_bh(&dev->dev_lock); - rc = scst_cm_send_init_inquiry(dev, scst_cm_get_lun(dev), NULL); + lun = scst_cm_get_lun(dev); + if (WARN_ON_ONCE(lun == SCST_MAX_LUN)) + goto out_unblock; + + rc = scst_cm_send_init_inquiry(dev, lun, NULL); if (rc != 0) goto out_unblock; @@ -2701,6 +2710,7 @@ out_resume: mutex_unlock(&scst_mutex); scst_resume_activity(); +out: TRACE_EXIT(); return;