Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2120011ioo; Mon, 23 May 2022 10:29:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOH6PZrc1d/LWBfK5VTn7P3fQBbnTRJ8+c3WewB+I3nPqHrMYwPcEQZxxN0DKsG+KMO0nC X-Received: by 2002:a17:902:dac7:b0:161:c7ed:38e1 with SMTP id q7-20020a170902dac700b00161c7ed38e1mr24063450plx.55.1653326968257; Mon, 23 May 2022 10:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653326968; cv=none; d=google.com; s=arc-20160816; b=p88VY1tSFX225ASs/3WuyNBw0eE4Q+ApEFppPDJtWCT/+3CCL1XlSCzZmqafXkz0sP s0HqVVttjJgv2ec2SaI6Vw5SKaHCdCdrdg9/l/N2yaK1yrPVvsTYzc6d7LstdmfJzMHi UrGGgcFq5QoMJgIoFA7GLtfr4dx0463ve6P6o7etuZewK1cs9qSPpjEdOh0rA89e4epw 6U64q6E+AjDgCibZF0PTJOeX9ieEyNkKOTK09iBDLQedHB6K6kAH7HpUKagJfNz1BdDi c3vCcVjf3DqQCHGE9tAsmVp4wjlC8Rgg6iRrD5wQZFg81opiBLa/+HXtQTGjVtmAys4E w2rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bvcnkNiIPIBkB6mfmVZ6c8vE96cDHQnebmNgI/ZxAMY=; b=QEObSLpxeDd6tefEeWZYlqLFP0OHDkyttYAwBiZJ0pvqRFVveuDvcnNdIxwxddrI9a znRcZ+PfuRRyZNEoNn1e2EcYmGjvF3NOA1SiIbiRHTEoV8fklaj0dgwZad9YAuaxgpyn iSWG+Z+0byiMFE1KdytieDS0NxULEo5DCsd42tMf+9jYTZjvnFukTwRVOIX+9U16E10I gbFevQ3oAd8NKEU1/jMdqk0GAcLRTx7TIlWNFxo/j0TBCAaQiz9+BllGIcEyIZzMuyL4 nPT/HvbDidockylUrgywvC1P/BW42Se3dC23G7pDz1klVyx4d2Eq3dXAnsQOEjfiwPSE PWJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eA+oX7x3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i17-20020a170902cf1100b00161a72f1966si10138574plg.421.2022.05.23.10.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:29:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eA+oX7x3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 52698814AE; Mon, 23 May 2022 10:29:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241836AbiEWR1Q (ORCPT + 99 others); Mon, 23 May 2022 13:27:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240254AbiEWRQL (ORCPT ); Mon, 23 May 2022 13:16:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C8FD694AD; Mon, 23 May 2022 10:12:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EB96E614F5; Mon, 23 May 2022 17:12:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 002B4C385A9; Mon, 23 May 2022 17:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325966; bh=AEH/dvMVbcFeYDvFezpfR84pX6HTZhUBNCCoNrj0aKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eA+oX7x3fwZjy11SHoctd9a6H/bF9ur1u97pBx+Befi0yZI4BGyu4jdclyHv3Qfys qL7AKXMbn5NDoEweWO0FufZYonGmB1pN7tJt0seNYQUhD261HcdnKEpay1DTLa4YDR Z//vLS3P4t5YAXjX4KwdjcvjpHZSEaO/c9+y82Eo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , Gleb Chesnokov , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 37/44] scsi: qla2xxx: Fix missed DMA unmap for aborted commands Date: Mon, 23 May 2022 19:05:21 +0200 Message-Id: <20220523165800.168103002@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165752.797318097@linuxfoundation.org> References: <20220523165752.797318097@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gleb Chesnokov [ Upstream commit 26f9ce53817a8fd84b69a73473a7de852a24c897 ] Aborting commands that have already been sent to the firmware can cause BUG in qlt_free_cmd(): BUG_ON(cmd->sg_mapped) For instance: - Command passes rdx_to_xfer state, maps sgl, sends to the firmware - Reset occurs, qla2xxx performs ISP error recovery, aborts the command - Target stack calls qlt_abort_cmd() and then qlt_free_cmd() - BUG_ON(cmd->sg_mapped) in qlt_free_cmd() occurs because sgl was not unmapped Thus, unmap sgl in qlt_abort_cmd() for commands with the aborted flag set. Link: https://lore.kernel.org/r/AS8PR10MB4952D545F84B6B1DFD39EC1E9DEE9@AS8PR10MB4952.EURPRD10.PROD.OUTLOOK.COM Reviewed-by: Himanshu Madhani Signed-off-by: Gleb Chesnokov Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/qla2xxx/qla_target.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 09c52ef66887..27d3293eadf5 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3753,6 +3753,9 @@ int qlt_abort_cmd(struct qla_tgt_cmd *cmd) spin_lock_irqsave(&cmd->cmd_lock, flags); if (cmd->aborted) { + if (cmd->sg_mapped) + qlt_unmap_sg(vha, cmd); + spin_unlock_irqrestore(&cmd->cmd_lock, flags); /* * It's normal to see 2 calls in this path: -- 2.35.1