Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3688104lfo; Mon, 23 May 2022 11:29:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU+/11IIEgQ9Szwn7L20JDvOzmkMWRHFavmpsLc1igGTjk2ilEqmSSrWerGjVG6vfpyCM6 X-Received: by 2002:a63:234f:0:b0:3fa:5513:b565 with SMTP id u15-20020a63234f000000b003fa5513b565mr5146433pgm.551.1653330544602; Mon, 23 May 2022 11:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330544; cv=none; d=google.com; s=arc-20160816; b=OqqS/Zr/DwQwcpKPa6B3sobP9yFME3/UQfHh/nxpfPonERXhnZlR76g6tmSdg4FGyg 9CmHifzu+o+fNKGFm2e7LYdHq1FCR3vaymqx8kMgyE+jOdqCh7M+hiQiyDLn5Iz6YlWz VEvq9qzkByqovtHzK6cZ53e1PwwzgeNXZR+CZ5cbRuHKFUGEkPa3x03ZWAXUZ1Nv+tYD czhcS+J5FkQagN5SXO9pBYlfGpsIsK4bqLzVA/whd6xqT3LyO8s/dTQrc60DKiU7ywE2 v3dLdHPUm0fjb4OQMcA/630UdZoJMWReTbPrkTq9NXVOk7EWhaHXk9QHGUv9AZAj2vBM +Log== 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=MrPyoxaH9ek7cq2mY6Hkt08F/rSDtcX/Vkp8Bq+xMks=; b=SYvXHZUP+lAIHk+JsB8/Sqz8Hfa+m3undn/ZDC/HBwSAcoO7/Zipg4fU7xPCzEfTO6 i2N58FDJvayD2zCZensj/jJwsx0Hy8EoyYdpxLaXFWXOyId1hyH7oWdYpHtDqPTTJ4Ah pWVN7K5DqMI1c1GM7FdeSSLGt6rQMnP3qvA3IIr0XMb2MkwokjlnsjFiE7RCAYc93acU Kz1gbLSbVjth5Da9DX8wwqzX9SEhXLHf7GpWHkZIL5OWqTG6R+K4jUF807uhVuUDXE/r tmW4PclfB2UZW9jn0M2PQOhd8Tlz5aRwtgoi21yamaDZlHHXiNfFwhY+JmLYSm//87sQ HgyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LwkaZ1V5; 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 b15-20020a17090aa58f00b001cd6a811925si68453pjq.48.2022.05.23.11.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:29:04 -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=LwkaZ1V5; 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 46D65E52B5; Mon, 23 May 2022 11:28:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240593AbiEWRYh (ORCPT + 99 others); Mon, 23 May 2022 13:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240505AbiEWRQY (ORCPT ); Mon, 23 May 2022 13:16:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2DF76D3B5; Mon, 23 May 2022 10:15:07 -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 748AD61525; Mon, 23 May 2022 17:14:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77334C385A9; Mon, 23 May 2022 17:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326088; bh=PbB7C77+uD6w0+4mF6M8fnCmGhUXFeYrAwDI9Gltt64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LwkaZ1V5I7UdZ2oxw9uK93/6LQ1iC+Ejj8eo8NDpR31xSb+lU8uTfc/mHCDgW2nNA OuF1JwC7trkwHp7GEJHK3psp0GSygOfZujaZRfKPuqmGfs6zQkzSn/8aXYgmqDxATO SHMJtEDgUFlZTze9P5CjwvgqRGt4iM9adVloBKIY= 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 5.4 53/68] scsi: qla2xxx: Fix missed DMA unmap for aborted commands Date: Mon, 23 May 2022 19:05:20 +0200 Message-Id: <20220523165811.258317918@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165802.500642349@linuxfoundation.org> References: <20220523165802.500642349@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 df598c377161..cb97565b6a33 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3768,6 +3768,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