Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2474776pxj; Mon, 10 May 2021 04:01:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn1ixpX8XDpbVPAFBsx0Y5uBxNu/Ee6KpNRUKHvD0Bh/m2DxL0m3hQor7TFs1HpskIhr8M X-Received: by 2002:a02:3505:: with SMTP id k5mr594401jaa.123.1620644467407; Mon, 10 May 2021 04:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644467; cv=none; d=google.com; s=arc-20160816; b=neayjdKNtS4hAfJi9dIbPUdl9NLzNKn4g9gbCYbgBzHcs04Dv+cvYSk9PsbZVrJAy3 30yz4sHhG8fsz8rWll+osCLNJ/AMLo5N+/GT4aIqQv/OhxNwa2yIJ6voRwBRU3iriWJX sO4DXjNRb6XX64RIZfRKb+gFM/ZO2g3nzPriPCwOL0Y4nywW9LUz8HwcK897VJsc3uDi CDqqWeaGapZC9HEcgWsvsoYoiZavcn2b6Zff/HHOVbC6HT1ae0cdHK+oPXdIfMP/xoon AeQ/HUaUcSPLj6W5FNuT2YA+jyGF0EfoDU9SWrxCWWFurSMRC36Bfu/ZkRFkQw1bz4VU 2EnA== 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=6QOhip7suOtP7irtUPoYcw5Nj6dx4oqwATapRVkjwc0=; b=siks2Nrca+bhHHFcTuILaNVUUI6qAd1BdoN8QmPJhR0pK0JJ1Pcwa8Tjd0RvcaRMfn NY8aY6ZjJNEsJNJYQfuBbtYL/wgNasXQFeP+uoQ4tBpsp64O2/3l10/mcH7c0MInpWJo R8N6D62OBYRnpCdQvvZ0/xFBriP/gez3+FeQha9KCSBghrcFJsefP13v/wGZN7kOtC/9 p2LZ/nKVc8pSWEaVjN8Qk0fEBim3RMuDCuUWAy+FVMC9NpVUTHMXPzV7XcCpXTuiI71m LDR1aHhsd/ZV5PFy0h+cKConvf5sERGVfOLpmpdLh4xYrzKEXmDvgEoVZSXRHlvt4lUt +/+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gWTSEKxg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si20018385jat.35.2021.05.10.04.00.54; Mon, 10 May 2021 04:01:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gWTSEKxg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233676AbhEJKzH (ORCPT + 99 others); Mon, 10 May 2021 06:55:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:59374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232518AbhEJKoY (ORCPT ); Mon, 10 May 2021 06:44:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D8956192F; Mon, 10 May 2021 10:33:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642800; bh=uJEarVN+vSHyAmItUIBdVzYMYsDhOhPXfqL5Dr3yHlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gWTSEKxgELbSbXtk3seBIPSK8eEa5l7RtsrcdCoiar7PksAsRp9pmEcacvYyZlsnD YwIiGr50p8EVlNW76k77lqO07/Ki1eM42iqTEfZfMLBi4R44C81oKnRox29vglqOYw jhCYPC34nRwkBzx4Q//SM9UnJPdrsOoEWgtBBJvY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Tang , Herbert Xu , Sasha Levin Subject: [PATCH 5.10 057/299] crypto: qat - fix unmap invalid dma address Date: Mon, 10 May 2021 12:17:34 +0200 Message-Id: <20210510102006.773732699@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hui Tang [ Upstream commit 792b32fad548281e1b7fe14df9063a96c54b32a2 ] 'dma_mapping_error' return a negative value if 'dma_addr' is equal to 'DMA_MAPPING_ERROR' not zero, so fix initialization of 'dma_addr'. Signed-off-by: Hui Tang Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/qat/qat_common/qat_algs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index d552dbcfe0a0..06abe1e2074e 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -670,7 +670,7 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, struct qat_alg_buf_list *bufl; struct qat_alg_buf_list *buflout = NULL; dma_addr_t blp; - dma_addr_t bloutp = 0; + dma_addr_t bloutp; struct scatterlist *sg; size_t sz_out, sz = struct_size(bufl, bufers, n + 1); @@ -682,6 +682,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, if (unlikely(!bufl)) return -ENOMEM; + for_each_sg(sgl, sg, n, i) + bufl->bufers[i].addr = DMA_MAPPING_ERROR; + blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, blp))) goto err_in; @@ -715,10 +718,14 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, dev_to_node(&GET_DEV(inst->accel_dev))); if (unlikely(!buflout)) goto err_in; + + bufers = buflout->bufers; + for_each_sg(sglout, sg, n, i) + bufers[i].addr = DMA_MAPPING_ERROR; + bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, bloutp))) goto err_out; - bufers = buflout->bufers; for_each_sg(sglout, sg, n, i) { int y = sg_nctr; -- 2.30.2