@@ -4677,9 +4677,10 @@ static
4677
4677
void qla24xx_create_new_sess (struct scsi_qla_host * vha , struct qla_work_evt * e )
4678
4678
{
4679
4679
unsigned long flags ;
4680
- fc_port_t * fcport = NULL ;
4680
+ fc_port_t * fcport = NULL , * tfcp ;
4681
4681
struct qlt_plogi_ack_t * pla =
4682
4682
(struct qlt_plogi_ack_t * )e -> u .new_sess .pla ;
4683
+ uint8_t free_fcport = 0 ;
4683
4684
4684
4685
spin_lock_irqsave (& vha -> hw -> tgt .sess_lock , flags );
4685
4686
fcport = qla2x00_find_fcport_by_wwpn (vha , e -> u .new_sess .port_name , 1 );
@@ -4694,6 +4695,7 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
4694
4695
pla -> ref_count -- ;
4695
4696
}
4696
4697
} else {
4698
+ spin_unlock_irqrestore (& vha -> hw -> tgt .sess_lock , flags );
4697
4699
fcport = qla2x00_alloc_fcport (vha , GFP_KERNEL );
4698
4700
if (fcport ) {
4699
4701
fcport -> d_id = e -> u .new_sess .id ;
@@ -4703,6 +4705,29 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
4703
4705
4704
4706
memcpy (fcport -> port_name , e -> u .new_sess .port_name ,
4705
4707
WWN_SIZE );
4708
+ } else {
4709
+ ql_dbg (ql_dbg_disc , vha , 0xffff ,
4710
+ "%s %8phC mem alloc fail.\n" ,
4711
+ __func__ , e -> u .new_sess .port_name );
4712
+
4713
+ if (pla )
4714
+ kmem_cache_free (qla_tgt_plogi_cachep , pla );
4715
+ return ;
4716
+ }
4717
+
4718
+ spin_lock_irqsave (& vha -> hw -> tgt .sess_lock , flags );
4719
+ /* search again to make sure one else got ahead */
4720
+ tfcp = qla2x00_find_fcport_by_wwpn (vha ,
4721
+ e -> u .new_sess .port_name , 1 );
4722
+ if (tfcp ) {
4723
+ /* should rarily happen */
4724
+ ql_dbg (ql_dbg_disc , vha , 0xffff ,
4725
+ "%s %8phC found existing fcport b4 add. DS %d LS %d\n" ,
4726
+ __func__ , tfcp -> port_name , tfcp -> disc_state ,
4727
+ tfcp -> fw_login_state );
4728
+
4729
+ free_fcport = 1 ;
4730
+ } else {
4706
4731
list_add_tail (& fcport -> list , & vha -> vp_fcports );
4707
4732
4708
4733
if (pla ) {
@@ -4720,6 +4745,12 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
4720
4745
else
4721
4746
qla24xx_async_gnl (vha , fcport );
4722
4747
}
4748
+
4749
+ if (free_fcport ) {
4750
+ qla2x00_free_fcport (fcport );
4751
+ if (pla )
4752
+ kmem_cache_free (qla_tgt_plogi_cachep , pla );
4753
+ }
4723
4754
}
4724
4755
4725
4756
void
0 commit comments