From patchwork Thu Oct 5 23:41:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satish Kharat X-Patchwork-Id: 9988143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F5B960291 for ; Thu, 5 Oct 2017 23:51:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 310FA28C59 for ; Thu, 5 Oct 2017 23:51:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2556F28D0D; Thu, 5 Oct 2017 23:51:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EEA728C59 for ; Thu, 5 Oct 2017 23:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751486AbdJEXvM (ORCPT ); Thu, 5 Oct 2017 19:51:12 -0400 Received: from alln-iport-4.cisco.com ([173.37.142.91]:46555 "EHLO alln-iport-4.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbdJEXvL (ORCPT ); Thu, 5 Oct 2017 19:51:11 -0400 X-Greylist: delayed 563 seconds by postgrey-1.27 at vger.kernel.org; Thu, 05 Oct 2017 19:51:11 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1194; q=dns/txt; s=iport; t=1507247471; x=1508457071; h=from:to:cc:subject:date:message-id; bh=Ty6qXUT7UyaaXPk9oBGg7pH0dgt5orc8yFgcGsuiZ2Y=; b=GpdcGnNnJjVkS/ojQ3Fs5K6wNPe/DSwC1rgUmheKXxnhNuoJeNFbEYsu 18D2v/hPyY9rxc33nIJwalANXOspUNfG/S/rUoir0QO4I0LHBR+wPqXcX JTJRBoejlbzv3sfjSgYDR9JTZAaYkMbHOXVfOn/wvhNP/g7/g33kDt4qj Q=; X-IronPort-AV: E=Sophos;i="5.42,482,1500940800"; d="scan'208";a="13245309" Received: from rcdn-core-12.cisco.com ([173.37.93.148]) by alln-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Oct 2017 23:41:47 +0000 Received: from satishkh.cisco.com ([10.157.132.70]) by rcdn-core-12.cisco.com (8.14.5/8.14.5) with ESMTP id v95NfleI021965; Thu, 5 Oct 2017 23:41:47 GMT From: satishkh@cisco.com To: linux-scsi@vger.kernel.org Cc: satishkh@cisco.com Subject: [PATCH 1/1] scsi/libfc: fix a deadlock in fc_rport_work Date: Thu, 5 Oct 2017 16:41:21 -0700 Message-Id: <1507246881-20508-1-git-send-email-satishkh@cisco.com> X-Mailer: git-send-email 2.5.5 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Satish Kharat In places like fc_rport_recv_plogi_req and fcoe_ctlr_vn_add we always take the lport disc_mutex lock before the rports mutex (rp_mutex) lock. Gaurding list_del_rcu(&rdata->peers) with disc.disc_mutex in fc_rport_work is correct but the rp_mutex lock can and should to be dropped before taking that lock else results in a deadlock. Signed-off-by: Satish Kharat Reviewed-by: Johannes Thumshirn --- drivers/scsi/libfc/fc_rport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 5203258..31d31aa 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -383,11 +383,11 @@ static void fc_rport_work(struct work_struct *work) fc_rport_enter_flogi(rdata); mutex_unlock(&rdata->rp_mutex); } else { + mutex_unlock(&rdata->rp_mutex); 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, fc_rport_destroy); } } else {