Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2111312ioo; Mon, 23 May 2022 10:17:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRVElBK6HbCr9ZPSEp9VXdmnp22Nkg4fX5sGcmLjDZaKGKa7jLkSstFNnXaJLXDErqIyub X-Received: by 2002:a05:6a00:1253:b0:518:7c1f:2a17 with SMTP id u19-20020a056a00125300b005187c1f2a17mr13891766pfi.72.1653326235546; Mon, 23 May 2022 10:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653326235; cv=none; d=google.com; s=arc-20160816; b=KrsrF5iRN1O2OM2q54SqH8iMSlkgbVVo9kmyMg7eX1mE2L7+zcqjaygR2vJpm/j6Np sGtl0nrcp7RSfhqjsd1SrWo0/JOaJieS1a626OrJe6nIS9q0xHVbH2H/u0YWHM6YRBaV +YgaMca/1Om522fPC/dKsy6493nq3P5swfEiFzBNTISFjKEbcgMv9yxJ+TMQMelE5QGJ S0OJyI4vi3Hp99tlO1RFe18IJL9/zjpqVmeZt2eAv9/U+EgstXrznEyd1JHf7avjVlq/ Efzj2P6VmeZI4rsIXCJ5tBpXTeOH1pO7+Sr0SjzKcssNkscWJWZ3dpcxJx5+af0Y5I88 mdMw== 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=AsDSjvj13U2Buq127te35lN8gBk2AttSC16XluqtHgY=; b=yYFaiiOKwP+uYAkw0jiD3VRvOXIRdlTgrQ4OzuWWSsYjQzuMWbmjz5hgk43ZmUBfdD fLvvbrpQk7LCUbCQT+hNmC8EJEr+DajL3zd2GK6arYHK97CLwGFtteKUY3SLvuJPhIyy jVkvAsBvJxyIqEdufKEGWIy4klvn90ubumWPjI0K17hqNIbHaf+Qlc0DTjdeAUPHZSxy ZDUUtm/hjcvdeh9ZJJFEycQwKduCEkmEnmxhnFoZ3HiNRxnqRfXG1GVTvE/it2DEz+S4 xVOTHw5d+Kgql/Pcu0Xg7sN8H7lUOic7hxgomDLd31o8BzyRqqVUbBHiujNLMCLOR+8G eu7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JQj1qBKE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id l6-20020a17090ad10600b001df76f9961asi13533657pju.184.2022.05.23.10.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:17:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JQj1qBKE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 97FBB7223D; Mon, 23 May 2022 10:15:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240335AbiEWRL5 (ORCPT + 99 others); Mon, 23 May 2022 13:11:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239728AbiEWRK3 (ORCPT ); Mon, 23 May 2022 13:10:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1DB66B7F8; Mon, 23 May 2022 10:10:00 -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 5DE00614CC; Mon, 23 May 2022 17:08:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60EA5C385A9; Mon, 23 May 2022 17:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325737; bh=1W2LW1qZ7oq6x4+GTpFCSF5m4dT2h7TD7pOzJu6tlbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JQj1qBKE0BysRV3ZXof16V06wU+nYt1HDw5lyD8+HAEUb6av/JfDDm+ArEvTBuhsr T6xwgB4sxPCy9bP7PZM025VwJVnCOM8bN68mLoiAajB2U/df62ApZ9xv+BAkmQOyAB DZkUceRBaj1/x5nStamvu8Vy2kCxzNy+Zw+xHjTA= 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.14 27/33] scsi: qla2xxx: Fix missed DMA unmap for aborted commands Date: Mon, 23 May 2022 19:05:16 +0200 Message-Id: <20220523165752.843430355@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165746.957506211@linuxfoundation.org> References: <20220523165746.957506211@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 97a0c2384aee..4b431ca55c96 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3639,6 +3639,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