From patchwork Wed Sep 5 13:53:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10588897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AACA180E for ; Wed, 5 Sep 2018 13:53:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AE6E28926 for ; Wed, 5 Sep 2018 13:53:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F72F2A206; Wed, 5 Sep 2018 13:53:52 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 CDD4C29CF7 for ; Wed, 5 Sep 2018 13:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbeIESYK (ORCPT ); Wed, 5 Sep 2018 14:24:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:59434 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727100AbeIESYK (ORCPT ); Wed, 5 Sep 2018 14:24:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 80BE3AF05; Wed, 5 Sep 2018 13:53:49 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Chad Dupuis , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 2/5] qedf: fixup locking in qedf_restart_rport() Date: Wed, 5 Sep 2018 15:53:44 +0200 Message-Id: <20180905135347.138195-3-hare@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180905135347.138195-1-hare@suse.de> References: <20180905135347.138195-1-hare@suse.de> 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 fc_rport_create() needs to be called with disc_mutex held. And we should re-assign the 'rdata' pointer in case it got changed. Signed-off-by: Hannes Reinecke --- drivers/scsi/qedf/qedf_els.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c index acb8157a96a8..f93379a4510c 100644 --- a/drivers/scsi/qedf/qedf_els.c +++ b/drivers/scsi/qedf/qedf_els.c @@ -363,9 +363,14 @@ void qedf_restart_rport(struct qedf_rport *fcport) "LOGO port_id=%x.\n", port_id); fc_rport_logoff(rdata); /* Recreate the rport and log back in */ + mutex_lock(&lport->disc.disc_mutex); rdata = fc_rport_create(lport, port_id); - if (rdata) + if (rdata) { + mutex_unlock(&lport->disc.disc_mutex); fc_rport_login(rdata); + fcport->rdata = rdata; + } else + mutex_unlock(&lport->disc.disc_mutex); } clear_bit(QEDF_RPORT_IN_RESET, &fcport->flags); }