From: Hannes Reinecke Date: Fri, 30 Sep 2016 09:01:15 +0000 (+0200) Subject: scsi: libfc: Fixup disc_mutex handling X-Git-Tag: v4.1.12-124.31.3~132 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=6f58c151fbd8fd3152fb3072eef45367963140ef;p=users%2Fjedix%2Flinux-maple.git scsi: libfc: Fixup disc_mutex handling The list of attached 'rdata' remote port structures is RCU protected, so there is no need to take the 'disc_mutex' when traversing it. Rather we should be using rcu_read_lock() and kref_get_unless_zero() to validate the entries. We need, however, take the disc_mutex when deleting an entry; otherwise we risk clashes with list_add. Orabug: 25933179 Reviewed-by: John Sobecki Signed-off-by: Hannes Reinecke Acked-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen Signed-off-by: Rajan Shanmugavelu Signed-off-by: Brian Maly --- diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 4ec896e42120..a0ceba10c679 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -378,7 +378,9 @@ static void fc_rport_work(struct work_struct *work) mutex_unlock(&rdata->rp_mutex); } else { FC_RPORT_DBG(rdata, "work delete\n"); + mutex_lock(&lport->disc.disc_mutex); list_del_rcu(&rdata->peers); + mutex_unlock(&lport->disc.disc_mutex); mutex_unlock(&rdata->rp_mutex); kref_put(&rdata->kref, lport->tt.rport_destroy); }