Received: by 10.213.65.68 with SMTP id h4csp425250imn; Tue, 13 Mar 2018 08:39:47 -0700 (PDT) X-Google-Smtp-Source: AG47ELsO8AnN6tPcm7i/GehFrKwp3CR7EaqAr/x5DmY5C+1Jnw5hl+t+PGF+4ldxWQRLIk4HoXwY X-Received: by 2002:a17:902:6789:: with SMTP id g9-v6mr962285plk.167.1520955587435; Tue, 13 Mar 2018 08:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520955587; cv=none; d=google.com; s=arc-20160816; b=uXQ9GRH67yGnHCF2imoJiv7UtccyCC7qjNozZjWj1nU1KW2oApITq3uVs+M3l46JDt tpvNnX/RoacyFLffFJK8LetLHoPcqbcc3zcMvNwX8QM6DTk2OEBIebZbU334lZuCo8BW BL+iKS9wKRkEgepGVRz8cAlXq4UC7Phe2UA/czVgKnFiShNBJA8wp39/fnNo858U5Ek1 XM8ToeRunCGugmVe9vJClXVZRvJd8lTSgAa6Vbok05aGnnjS5gAXef+4bqo6krD34wbf 3GUraRZqKZvXsCzJJ6zW219OiRs59ZOfsvTmLk/gdk5eclp9PoorvttEeJU2afwEZ9wy uT7g== 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=1UZrpghtiDRftR7DiDU+LjyPXbb436zfjNhHEI1NpD4=; b=zg+CWdIEQ3oYfLyGjj752HT6/IobePbRil9dUVDMXHRJ+ngLsSfHzGjarng4D2QSk0 NAd83fxmNGgrPFNS0hw2MOYaBOF6cewD2l09pG7wnGJCCYrtEEH+Xg60gQmvJaCFLhZk XZaFm6L/r7vPzdfDHIQLPBycUeHINc+Cupf0Ql0o1UcFlAIWMoniUX5ViXp6fkO38FGL VrrneqeB3N/S2dsk6yhm3zkJBVvcUu7GLDLLgbmTo4T2pS/ZYY+3imZTGk6lDnGDLueN 78WOrQ1imgZ79Zp4nRpGDfXKQqkd9XNT09E5quJa2qlllGb5SeT0yyRS+UomMsRvQzH6 MdTg== 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 v12-v6si289284plo.170.2018.03.13.08.39.27; Tue, 13 Mar 2018 08:39:47 -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 S934281AbeCMPg7 (ORCPT + 99 others); Tue, 13 Mar 2018 11:36:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33726 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753143AbeCMPgy (ORCPT ); Tue, 13 Mar 2018 11:36:54 -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 37822120F; Tue, 13 Mar 2018 15:36:53 +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.14 042/140] scsi: qla2xxx: Fix memory leak in dual/target mode Date: Tue, 13 Mar 2018 16:24:05 +0100 Message-Id: <20180313152500.944485328@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@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.14-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 @@ -8092,9 +8092,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); @@ -8102,6 +8099,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; }