Received: by 10.213.65.68 with SMTP id h4csp423260imn; Tue, 13 Mar 2018 08:35:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELvcOa5t5UilN1J1sTIGugFVnzjvnkmTHzf3zx4agciYqFgBXzP8qHCxNRj8bXsufsJKBaYG X-Received: by 10.98.112.6 with SMTP id l6mr1021547pfc.61.1520955358895; Tue, 13 Mar 2018 08:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520955358; cv=none; d=google.com; s=arc-20160816; b=zkEKsJB4vrewc1GDJfDsnF0IZay4gUt1q53SCEnVs8pwrV6uTzEJvoXmYck1sdCF3V He0UYuzZgvxrpLA2h6vju92A1hLrKBysc4g1WIayHNrSd4xppncgrGeJG4jZZdOA1TEm 6rOHvITAmAWatZFaJozpB36jNAvrAKS2WCWmEKDaU6wtdYblx/PDKsFP0lRdDf2GGeDl rwFlA8Ruc2mQHSSU8vhzQc/UgQF31CMbhPp1O6ZL0sSUxQLMQ5zGk1jIXcUgMsspgboZ t6NEvwxT2QZS+9HwYafxXOuZ694jyBC8FdHQcsNhgqol01UNuwR3ghdyN6bb6JB8e744 MSXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=E3zmn20R/5PlTT0hH1Xba/hRrvi7dEfMrQhJC7u8NgU=; b=fjV1F6LOZIfYSdk9tEpkrIDHfvZPMWyfPtPYqoMsWU0ckyKXcxnfrBSZr3KBS4Dz1p usvTJ8sB8/zydKY493WoC3WkpVmRefYoTAeL16d89C5lH/w9SO8oF6mZc9gbqMhvWrM3 VkRaRNwQzWflkdrQcn6zOcNKunQMkCBH9F7tA7o/iWPif4BZ+18vArbKYzKgNio40nma Y5Y8qilbEDYUWqdDzIFJjoDHB6EShlfAT+IGGlv2wXgppsh5/8HMlnzZn5o/nz+IBi3R g2SDcj7z0jVS2viS7S2SvbmiJ13k3NsxpMCAKfFVss+IBKMTTflnZY7sO2gAdjjLrKrr A/4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si257000pga.503.2018.03.13.08.35.44; Tue, 13 Mar 2018 08:35:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933745AbeCMPeU (ORCPT + 99 others); Tue, 13 Mar 2018 11:34:20 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32786 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933734AbeCMPeS (ORCPT ); Tue, 13 Mar 2018 11:34:18 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 841D41035; Tue, 13 Mar 2018 15:34:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , Hannes Reinecke , "Martin K. Petersen" Subject: [PATCH 4.15 143/146] scsi: qla2xxx: Fix memory leak in dual/target mode Date: Tue, 13 Mar 2018 16:25:10 +0100 Message-Id: <20180313152331.118606115@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: himanshu.madhani@cavium.com commit 7867b98dceb7741065c9c1b645136facad5c2e93 upstream. When driver is loaded in Target/Dual mode, it creates QPair to support MQ and allocates resources for each QPair. This Qpair initialization is delayed until the FW personality is changed to Dual/Target mode by issuing chip reset. At the time of chip reset firmware is re-initilized in correct personality all the QPairs are initialized by sending MBC_INITIALIZE_MULTIQ (001Fh). This patch fixes memory leak by adding check to issue MBC_INITIALIZE_MULTIQ command only while deleting rsp/req queue when the flag is set for initiator mode, and clean up QPair resources correctly during the driver unload. This MBX does not need to be issued for Target/Dual mode because chip reset will reset ISP. Fixes: d65237c7f0860 ("scsi: qla2xxx: Fix mailbox failure while deleting Queue pairs") Cc: # 4.10+ Signed-off-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_init.c | 4 +--- drivers/scsi/qla2xxx/qla_mid.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -8221,9 +8221,6 @@ int qla2xxx_delete_qpair(struct scsi_qla int ret = QLA_FUNCTION_FAILED; struct qla_hw_data *ha = qpair->hw; - if (!vha->flags.qpairs_req_created && !vha->flags.qpairs_rsp_created) - goto fail; - qpair->delete_in_progress = 1; while (atomic_read(&qpair->ref_count)) msleep(500); @@ -8231,6 +8228,7 @@ int qla2xxx_delete_qpair(struct scsi_qla ret = qla25xx_delete_req_que(vha, qpair->req); if (ret != QLA_SUCCESS) goto fail; + ret = qla25xx_delete_rsp_que(vha, qpair->rsp); if (ret != QLA_SUCCESS) goto fail; --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -575,14 +575,15 @@ qla25xx_free_rsp_que(struct scsi_qla_hos int qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req) { - int ret = -1; + int ret = QLA_SUCCESS; - if (req) { + if (req && vha->flags.qpairs_req_created) { req->options |= BIT_0; ret = qla25xx_init_req_que(vha, req); + if (ret != QLA_SUCCESS) + return QLA_FUNCTION_FAILED; } - if (ret == QLA_SUCCESS) - qla25xx_free_req_que(vha, req); + qla25xx_free_req_que(vha, req); return ret; } @@ -590,14 +591,15 @@ qla25xx_delete_req_que(struct scsi_qla_h int qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) { - int ret = -1; + int ret = QLA_SUCCESS; - if (rsp) { + if (rsp && vha->flags.qpairs_rsp_created) { rsp->options |= BIT_0; ret = qla25xx_init_rsp_que(vha, rsp); + if (ret != QLA_SUCCESS) + return QLA_FUNCTION_FAILED; } - if (ret == QLA_SUCCESS) - qla25xx_free_rsp_que(vha, rsp); + qla25xx_free_rsp_que(vha, rsp); return ret; }