scst_copy_mgr: Avoid that LUN removal triggers a BUG()

Reported-by: Jinpu Wang <jinpu.wang@profitbricks.com>


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7096 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2017-02-24 02:08:17 +00:00
parent 585c5d2fe0
commit ab0e7cc0be

View File

@@ -2522,9 +2522,8 @@ static bool scst_cm_is_lun_free(unsigned int lun)
static unsigned int scst_cm_get_lun(const struct scst_device *dev)
{
unsigned int res = -1;
unsigned int res = SCST_MAX_LUN;
int i;
bool found = false;
TRACE_ENTRY();
@@ -2538,7 +2537,6 @@ static unsigned int scst_cm_get_lun(const struct scst_device *dev)
list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) {
if (tgt_dev->dev == dev) {
res = tgt_dev->lun;
found = true;
TRACE_DBG("LUN %d found (full LUN %lld)",
res, tgt_dev->lun);
goto out;
@@ -2546,8 +2544,6 @@ static unsigned int scst_cm_get_lun(const struct scst_device *dev)
}
}
sBUG_ON(!found);
out:
TRACE_EXIT_RES(res);
return res;