From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 027CD14A4CF; Tue, 23 Jan 2024 00:20:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705969229; cv=none; b=PAKodAf1/ZppvNvnLVCNtoGN+lMJrvOk5lBmKVc20J45THibDLQ7pc2SsmF44iQ/zYTHkcHWuhLbQk6VzlctTLw0uxOxp62Ij+1rAT3krN2Oft61JMBvy/T1TwKHTLwDZG+7I+5R2ZiIg1caeB//jhwIFh4UDGBePA4iN3FDAjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705969229; c=relaxed/simple; bh=EJhMUQFAfxA6imdWC0thriRMmex2pI2NIcN4+fH62ok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HlRustMhTyWgUKt6kFNe3p60rFmXPgyqX83ZTmPlq4JEjjJqK6uXvQ0MMtlC7QjYmDlELoNWD0EhUd9rnf7ZAO9nMYHwWp6SIqFqfDMSmjBCRvrD2O+Q62rrHHz+im4ihgOSYLSE5a+g8dTvZiUNM8SHJ02rPhoe2QkCHWXo95I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=T2uBR3D0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="T2uBR3D0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD0D2C433C7; Tue, 23 Jan 2024 00:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705969228; bh=EJhMUQFAfxA6imdWC0thriRMmex2pI2NIcN4+fH62ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T2uBR3D0bPHKJFnzpE1W26tLOusUtcMyPNPfIWMJgWgKhvkflbVT2rLwI4CX36H1J goUdIUTg6sANDnCd2jUGdwncNWe/UELy+7JMuQE5+mAjXv9lqxOZSkHAWcqUxW19vr pz/jaMUI4sGCUmEBqUNaBvcBC/PX9JqnijZ3suVA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ovidiu Panait , Herbert Xu , Sasha Levin Subject: [PATCH 6.7 078/641] crypto: sahara - fix wait_for_completion_timeout() error handling Date: Mon, 22 Jan 2024 15:49:42 -0800 Message-ID: <20240122235820.476573075@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235818.091081209@linuxfoundation.org> References: <20240122235818.091081209@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.7-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ovidiu Panait [ Upstream commit 2dba8e1d1a7957dcbe7888846268538847b471d1 ] The sg lists are not unmapped in case of timeout errors. Fix this. Fixes: 5a2bb93f5992 ("crypto: sahara - add support for SHA1/256") Fixes: 5de8875281e1 ("crypto: sahara - Add driver for SAHARA2 accelerator.") Signed-off-by: Ovidiu Panait Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/sahara.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index 31973e6ce520..3661f02d131a 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -607,16 +607,17 @@ static int sahara_aes_process(struct skcipher_request *req) timeout = wait_for_completion_timeout(&dev->dma_completion, msecs_to_jiffies(SAHARA_TIMEOUT_MS)); - if (!timeout) { - dev_err(dev->device, "AES timeout\n"); - return -ETIMEDOUT; - } dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg, DMA_FROM_DEVICE); dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg, DMA_TO_DEVICE); + if (!timeout) { + dev_err(dev->device, "AES timeout\n"); + return -ETIMEDOUT; + } + if ((dev->flags & FLAGS_CBC) && req->iv) sahara_aes_cbc_update_iv(req); @@ -1007,15 +1008,16 @@ static int sahara_sha_process(struct ahash_request *req) timeout = wait_for_completion_timeout(&dev->dma_completion, msecs_to_jiffies(SAHARA_TIMEOUT_MS)); - if (!timeout) { - dev_err(dev->device, "SHA timeout\n"); - return -ETIMEDOUT; - } if (rctx->sg_in_idx) dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg, DMA_TO_DEVICE); + if (!timeout) { + dev_err(dev->device, "SHA timeout\n"); + return -ETIMEDOUT; + } + memcpy(rctx->context, dev->context_base, rctx->context_size); if (req->result && rctx->last) -- 2.43.0