Commit b73aa56e authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi: libfc: safeguard against invalid exchange index

The cached exchange index might be invalid, in which case
we should drop down to allocate a new one.
And we should not try to access an invalid exchange when
responding to a BA_ABTS.
Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 5d339d16
......@@ -827,14 +827,18 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
/* peek cache of free slot */
if (pool->left != FC_XID_UNKNOWN) {
index = pool->left;
pool->left = FC_XID_UNKNOWN;
goto hit;
if (!WARN_ON(fc_exch_ptr_get(pool, pool->left))) {
index = pool->left;
pool->left = FC_XID_UNKNOWN;
goto hit;
}
}
if (pool->right != FC_XID_UNKNOWN) {
index = pool->right;
pool->right = FC_XID_UNKNOWN;
goto hit;
if (!WARN_ON(fc_exch_ptr_get(pool, pool->right))) {
index = pool->right;
pool->right = FC_XID_UNKNOWN;
goto hit;
}
}
index = pool->next_index;
......@@ -1782,7 +1786,10 @@ static void fc_exch_recv_bls(struct fc_exch_mgr *mp, struct fc_frame *fp)
fc_frame_free(fp);
break;
case FC_RCTL_BA_ABTS:
fc_exch_recv_abts(ep, fp);
if (ep)
fc_exch_recv_abts(ep, fp);
else
fc_frame_free(fp);
break;
default: /* ignore junk */
fc_frame_free(fp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment